Handle timeout
This commit is contained in:
parent
5853e99e7b
commit
298e385dae
1 changed files with 10 additions and 2 deletions
|
@ -6,8 +6,8 @@
|
||||||
struct waited_pkt {
|
struct waited_pkt {
|
||||||
uint16_t id;
|
uint16_t id;
|
||||||
int link_num;
|
int link_num;
|
||||||
int timer_fd;
|
|
||||||
uint8_t on;
|
uint8_t on;
|
||||||
|
int timer_fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct deferred_pkt {
|
struct deferred_pkt {
|
||||||
|
@ -102,6 +102,7 @@ int set_timeout(struct evt_core_ctx* evts, uint64_t micro_sec, struct waited_pkt
|
||||||
fdinfo.free_other = NULL;
|
fdinfo.free_other = NULL;
|
||||||
sprintf(fdinfo.url, "timer:%ld:1", micro_sec);
|
sprintf(fdinfo.url, "timer:%ld:1", micro_sec);
|
||||||
evt_core_add_fd (evts, &fdinfo);
|
evt_core_add_fd (evts, &fdinfo);
|
||||||
|
|
||||||
return fdinfo.fd;
|
return fdinfo.fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ void rr_pkt_register(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo,
|
||||||
rr->wait[idx_waited].on = 1;
|
rr->wait[idx_waited].on = 1;
|
||||||
rr->wait[idx_waited].id = bp->ip.ap.str.id;
|
rr->wait[idx_waited].id = bp->ip.ap.str.id;
|
||||||
rr->wait[idx_waited].link_num = bp->ip.ap.str.prevlink;
|
rr->wait[idx_waited].link_num = bp->ip.ap.str.prevlink;
|
||||||
set_timeout(ctx, timeout, &rr->wait[idx_waited]);
|
rr->wait[idx_waited].timer_fd = set_timeout(ctx, timeout, &rr->wait[idx_waited]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. We queue the packet
|
// 4. We queue the packet
|
||||||
|
@ -255,7 +256,14 @@ int rr_on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
||||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||||
struct rr_ctx* rr = app_ctx->misc;
|
struct rr_ctx* rr = app_ctx->misc;
|
||||||
|
|
||||||
|
struct waited_pkt* pkt = fdinfo->other;
|
||||||
|
pkt->on = 0;
|
||||||
|
evt_core_rm_fd(ctx, fdinfo->fd);
|
||||||
|
|
||||||
|
rr->remote_links &= 0xffff ^ 1 << pkt->link_num;
|
||||||
|
rr->recv_id = pkt->id;
|
||||||
|
|
||||||
|
rr_pkt_unroll (ctx, app_ctx);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue