qpid-proton git commit: PROTON-1538: epoll proactor - prevent out of order rearming of connection file descriptor

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

qpid-proton git commit: PROTON-1538: epoll proactor - prevent out of order rearming of connection file descriptor

cliffjansen
Repository: qpid-proton
Updated Branches:
  refs/heads/master 0ee215539 -> 79309b030


PROTON-1538: epoll proactor - prevent out of order rearming of connection file descriptor


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

Branch: refs/heads/master
Commit: 79309b030476f4957f7d8f360d2224ee0850e006
Parents: 0ee2155
Author: Clifford Jansen <[hidden email]>
Authored: Fri Aug 11 10:53:12 2017 -0700
Committer: Clifford Jansen <[hidden email]>
Committed: Fri Aug 11 10:55:42 2017 -0700

----------------------------------------------------------------------
 proton-c/src/proactor/epoll.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/79309b03/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 9ece597..fdb660c 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -516,6 +516,7 @@ typedef struct pconnection_t {
   struct pn_netaddr_t local, remote; /* Actual addresses */
   struct addrinfo *addrinfo;         /* Resolved address list */
   struct addrinfo *ai;               /* Current connect address */
+  pmutex rearm_mutex;                /* protects pconnection_rearm from out of order arming*/
 } pconnection_t;
 
 struct pn_listener_t {
@@ -727,6 +728,7 @@ static pconnection_t *new_pconnection_t(pn_proactor_t *p, pn_connection_t *c, bo
     psocket_error(&pc->psocket, errno, "timer setup");
     pc->disconnected = true;    /* Already failed */
   }
+  pmutex_init(&pc->rearm_mutex);
 
   pn_decref(pc);                /* Will be deleted when the connection is */
   return pc;
@@ -742,6 +744,7 @@ static void pconnection_final_free(pconnection_t *pc) {
   if (pc->addrinfo) {
     freeaddrinfo(pc->addrinfo);
   }
+  pmutex_finalize(&pc->rearm_mutex);
   pn_condition_free(pc->disconnect_condition);
   pn_incref(pc);                /* Make sure we don't do a circular free */
   pn_connection_driver_destroy(&pc->driver);
@@ -847,14 +850,16 @@ static bool pconnection_rearm_check(pconnection_t *pc) {
   }
   if (!wanted_now || pc->current_arm == wanted_now) return false;
 
+  lock(&pc->rearm_mutex);      /* unlocked in pconnection_rearm... */
   pc->psocket.epoll_io.wanted = wanted_now;
   pc->current_arm = wanted_now;
-  return true;
+  return true;                     /* ... so caller MUST call pconnection_rearm */
 }
 
 /* Call without lock */
 static inline void pconnection_rearm(pconnection_t *pc) {
   rearm(pc->psocket.proactor, &pc->psocket.epoll_io);
+  unlock(&pc->rearm_mutex);
 }
 
 static inline bool pconnection_work_pending(pconnection_t *pc) {


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

Loading...