You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/03/22 16:01:07 UTC

[3/3] qpid-proton git commit: PROTON-1438: C libuv proactor, fix occasional timeout hangs

PROTON-1438: C libuv proactor, fix occasional timeout hangs


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b143db26
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b143db26
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b143db26

Branch: refs/heads/master
Commit: b143db26fe81567764f182ea17147169d5d17e3b
Parents: ce1b3d1
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Mar 22 11:30:30 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Mar 22 11:32:33 2017 -0400

----------------------------------------------------------------------
 proton-c/src/proactor/libuv.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b143db26/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index a077a5f..8fc3eaf 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -737,6 +737,7 @@ static void on_timeout(uv_timer_t *timer) {
   pn_proactor_t *p = (pn_proactor_t*)timer->data;
   uv_mutex_lock(&p->lock);
   p->timeout_elapsed = true;
+  uv_stop(&p->loop);            /* UV does not always stop after on_timeout without this */
   uv_mutex_unlock(&p->lock);
 }
 
@@ -881,6 +882,14 @@ void pconnection_detach(pconnection_t *pc) {
 
 /* Process the leader_q and the UV loop, in the leader thread */
 static pn_event_batch_t *leader_lead_lh(pn_proactor_t *p, uv_run_mode mode) {
+  /* Set timeout timer if there was a request, let it count down while we process work */
+  if (p->timeout_request) {
+    p->timeout_request = false;
+    uv_timer_stop(&p->timer);
+    if (p->timeout) {
+      uv_timer_start(&p->timer, on_timeout, p->timeout, 0);
+    }
+  }
   pn_event_batch_t *batch = NULL;
   for (work_t *w = work_pop(&p->leader_q); w; w = work_pop(&p->leader_q)) {
     assert(!w->working);
@@ -909,14 +918,6 @@ static pn_event_batch_t *leader_lead_lh(pn_proactor_t *p, uv_run_mode mode) {
   }
   batch = get_batch_lh(p);      /* Check for work */
   if (!batch) { /* No work, run the UV loop */
-    /* Set timeout timer before uv_run */
-    if (p->timeout_request) {
-      p->timeout_request = false;
-      uv_timer_stop(&p->timer);
-      if (p->timeout) {
-        uv_timer_start(&p->timer, on_timeout, p->timeout, 0);
-      }
-    }
     uv_mutex_unlock(&p->lock);  /* Unlock to run UV loop */
     uv_run(&p->loop, mode);
     uv_mutex_lock(&p->lock);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org