Add missing features to health packet
This commit is contained in:
parent
5bcab96393
commit
67a3c2a610
1 changed files with 26 additions and 15 deletions
|
@ -65,21 +65,6 @@ void rr_pkt_register(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo,
|
||||||
|
|
||||||
//printf("Selected url %s for pkt %d to be queued for delivery\n", fdinfo->url, bp->ip.ap.str.id);
|
//printf("Selected url %s for pkt %d to be queued for delivery\n", fdinfo->url, bp->ip.ap.str.id);
|
||||||
|
|
||||||
// 0. Update remote links
|
|
||||||
if (ring_lt(rr->recv_id_late, bp->ip.ap.str.id) && !(rr->remote_links & 1 << link_num)) {
|
|
||||||
printf("Activate link=%d | ", link_num);
|
|
||||||
rr->remote_links |= 1 << link_num; // Make sure that the link is marked as working
|
|
||||||
show_link_availability (rr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Update my links I can use thanks to target feedback
|
|
||||||
if (bp->ip.ap.str.id > rr->my_links_ver && bp->ip.ap.str.bitfield != rr->my_links) {
|
|
||||||
rr->my_links = bp->ip.ap.str.bitfield;
|
|
||||||
rr->my_links_ver = bp->ip.ap.str.id;
|
|
||||||
printf("Update my links | ");
|
|
||||||
show_link_availability (rr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. If packet arrived too late or already queued, we discard it
|
// 2. If packet arrived too late or already queued, we discard it
|
||||||
if (ring_ge(rr->recv_id, bp->ip.ap.str.id) || rr->real[real_idx].id == bp->ip.ap.str.id) {
|
if (ring_ge(rr->recv_id, bp->ip.ap.str.id) || rr->real[real_idx].id == bp->ip.ap.str.id) {
|
||||||
// Packet has already been delivered or dropped, we free the buffer
|
// Packet has already been delivered or dropped, we free the buffer
|
||||||
|
@ -175,8 +160,34 @@ void rr_pkt_manage_links(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinf
|
||||||
|
|
||||||
assert(bp->ip.ap.headers.cmd == CMD_HEALTH);
|
assert(bp->ip.ap.headers.cmd == CMD_HEALTH);
|
||||||
|
|
||||||
|
// 1. Health packet was received too late, dropping it
|
||||||
if (ring_le(bp->ip.ap.health.id, rr->health_id_late)) goto release;
|
if (ring_le(bp->ip.ap.health.id, rr->health_id_late)) goto release;
|
||||||
|
|
||||||
|
// 2. Reactivate link if deactivated
|
||||||
|
char buffer[16];
|
||||||
|
url_get_port (buffer, fdinfo->url);
|
||||||
|
int link_num = atoi(buffer) - 7500; // @FIXME Hardcoded
|
||||||
|
if (!(rr->remote_links & (1 << link_num))) {
|
||||||
|
printf("Activate link=%d | ", link_num);
|
||||||
|
rr->remote_links |= 1 << link_num; // Make sure that the link is marked as working
|
||||||
|
show_link_availability (rr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Update RR structure if its the greatest health_id we received
|
||||||
|
if (ring_gt(bp->ip.ap.health.id, rr->health_id)) {
|
||||||
|
// 3.1. Update current health id
|
||||||
|
rr->health_id = bp->ip.ap.health.id;
|
||||||
|
|
||||||
|
// 3.2. Update my links I can use thanks to target feedback
|
||||||
|
if (bp->ip.ap.str.bitfield != rr->my_links) {
|
||||||
|
rr->my_links = bp->ip.ap.str.bitfield;
|
||||||
|
rr->my_links_ver = bp->ip.ap.str.id;
|
||||||
|
printf("Update my links | ");
|
||||||
|
show_link_availability (rr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Set callback to close this health packet window
|
||||||
int64_t timeout = rr->mjit - (int64_t) bp->ip.ap.content.health.deltat;
|
int64_t timeout = rr->mjit - (int64_t) bp->ip.ap.content.health.deltat;
|
||||||
if (timeout <= 0) timeout = 0;
|
if (timeout <= 0) timeout = 0;
|
||||||
uint64_t idx = bp->ip.ap.content.health.id % PACKET_BUFFER_SIZE;
|
uint64_t idx = bp->ip.ap.content.health.id % PACKET_BUFFER_SIZE;
|
||||||
|
|
Loading…
Reference in a new issue