Repository: qpid-proton
Updated Branches:
  refs/heads/master 391ec64d9 -> 5eaf6666d


PROTON-1460: epoll proactor fixes for test_disconnect


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

Branch: refs/heads/master
Commit: 5eaf6666d581cec84b546e1dd9e4fa014b07a003
Parents: 391ec64
Author: Clifford Jansen <[email protected]>
Authored: Tue Apr 25 14:28:52 2017 -0700
Committer: Clifford Jansen <[email protected]>
Committed: Tue Apr 25 14:28:52 2017 -0700

----------------------------------------------------------------------
 proton-c/src/proactor/epoll.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5eaf6666/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 7f49928..b1175f4 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -722,7 +722,7 @@ static void pconnection_done(pconnection_t *pc) {
   pc->hog_count = 0;
   if (pconnection_has_event(pc) || pconnection_work_pending(pc)) {
     notify = wake(&pc->context);
-  } else if (!pc->read_closed && pn_connection_driver_finished(&pc->driver)) {
+  } else if (pc->read_closed && pn_connection_driver_finished(&pc->driver)) {
     pconnection_begin_close(pc);
     if (pconnection_is_final(pc)) {
       unlock(&pc->context.mutex);
@@ -1669,6 +1669,7 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
   bool notify = false;
   for (ps = disconnecting_psockets; ps; ps = ps->next) {
     bool do_free = false;
+    pcontext_t *psocket_context = NULL;
     pmutex *ps_mutex = NULL;
     pconnection_t *pc = as_pconnection(ps);
     if (pc) {
@@ -1679,6 +1680,8 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
           pn_condition_copy(pn_transport_condition(pc->driver.transport), 
cond);
         }
         pn_connection_driver_close(&pc->driver);
+        pc->read_closed = true;
+        psocket_context = &pc->context;
       }
     } else {
       pn_listener_t *l = as_listener(ps);
@@ -1689,17 +1692,24 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
         if (cond) {
           pn_condition_copy(pn_listener_condition(l), cond);
         }
-        pn_listener_close(l);
+        listener_begin_close(l);
+        psocket_context = &l->context;
       }
     }
 
     lock(&p->context.mutex);
     if (--ps->disconnect_ops == 0) {
       do_free = true;
+      psocket_context = NULL;
       if (--p->disconnects_pending == 0 && !p->psockets) {
         p->inactive = true;
         notify = wake(&p->context);
       }
+    } else {
+      // If initiating the close, wake the psocket to do the free.
+      if (psocket_context)
+        if (!wake(psocket_context))
+          psocket_context = NULL;  // Wake already pending.
     }
     unlock(&p->context.mutex);
     unlock(ps_mutex);
@@ -1707,13 +1717,15 @@ void pn_proactor_disconnect(pn_proactor_t *p, 
pn_condition_t *cond) {
     if (do_free) {
       if (pc) pconnection_final_free(pc);
       else listener_final_free(as_listener(ps));
+    } else {
+      if (psocket_context)
+        wake_notify(psocket_context);
     }
   }
   if (notify)
     wake_notify(&p->context);
 }
 
-
 const struct sockaddr_storage *pn_proactor_addr_sockaddr(const 
pn_proactor_addr_t *addr) {
   assert(false);
   return NULL;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to