PROTON-1564: epoll proactor determine inactive state after timeout callback instead of before
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ba696d24 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ba696d24 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ba696d24 Branch: refs/heads/go1 Commit: ba696d242787429d164fde2932b558a62b526fbc Parents: 2806140 Author: Clifford Jansen <[email protected]> Authored: Wed Aug 30 15:44:25 2017 -0700 Committer: Clifford Jansen <[email protected]> Committed: Wed Aug 30 15:44:25 2017 -0700 ---------------------------------------------------------------------- proton-c/src/proactor/epoll.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ba696d24/proton-c/src/proactor/epoll.c ---------------------------------------------------------------------- diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c index 9a29869..89cad31 100644 --- a/proton-c/src/proactor/epoll.c +++ b/proton-c/src/proactor/epoll.c @@ -381,6 +381,7 @@ struct pn_proactor_t { bool need_inactive; bool need_timeout; bool timeout_set; /* timeout has been set by user and not yet cancelled or generated event */ + bool timeout_processed; /* timout event dispatched in the most recent event batch */ bool timer_armed; /* timer is armed in epoll */ bool shutting_down; // wake subsystem @@ -1700,7 +1701,6 @@ static bool proactor_update_batch(pn_proactor_t *p) { p->need_timeout = false; p->timeout_set = false; proactor_add_event(p, PN_PROACTOR_TIMEOUT); - p->need_inactive = is_inactive(p); return true; } if (p->need_interrupt) { @@ -1721,6 +1721,8 @@ static pn_event_t *proactor_batch_next(pn_event_batch_t *batch) { lock(&p->context.mutex); proactor_update_batch(p); pn_event_t *e = pn_collector_next(p->collector); + if (e && pn_event_type(e) == PN_PROACTOR_TIMEOUT) + p->timeout_processed = true; unlock(&p->context.mutex); return log_event(p, e); } @@ -1896,9 +1898,15 @@ void pn_proactor_done(pn_proactor_t *p, pn_event_batch_t *batch) { bool rearm_timer = !p->timer_armed && !p->shutting_down; p->timer_armed = true; p->context.working = false; + if (p->timeout_processed) { + p->timeout_processed = false; + if (wake_if_inactive(p)) + notify = true; + } proactor_update_batch(p); if (proactor_has_event(p)) - notify = wake(&p->context); + if (wake(&p->context)) + notify = true; unlock(&p->context.mutex); if (notify) wake_notify(&p->context); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
