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/09/01 15:03:46 UTC

[18/50] qpid-proton git commit: PROTON-1538: epoll proactor - prevent out of order rearming of connection file descriptor

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/go1
Commit: 79309b030476f4957f7d8f360d2224ee0850e006
Parents: 0ee2155
Author: Clifford Jansen <cl...@apache.org>
Authored: Fri Aug 11 10:53:12 2017 -0700
Committer: Clifford Jansen <cl...@apache.org>
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: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org