qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [2/2] qpid-proton git commit: PROTON-1727 [epoll] fix race condition
Date Fri, 22 Dec 2017 17:13:29 GMT
PROTON-1727 [epoll] fix race condition

Needed to set current_arm flag on second and subsequent connect attempts when
resolve returns multiple socket addresses. Otherwise another thread can delete
the connection early.


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

Branch: refs/heads/master
Commit: 223e6d012dab8bbe4bdb92538d84c630bbd1cf27
Parents: 8d91e54
Author: Alan Conway <aconway@redhat.com>
Authored: Fri Dec 22 11:14:05 2017 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Fri Dec 22 12:11:10 2017 -0500

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


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/223e6d01/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index b4f08b7..8f6dacb 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -1096,6 +1096,7 @@ static pn_event_batch_t *pconnection_process(pconnection_t *pc, uint32_t
events,
   }
 
   if (pc->new_events) {
+    pc->current_arm = 0;
     if (!pc->context.closing) {
       if ((pc->new_events & (EPOLLHUP | EPOLLERR)) && !pconnection_rclosed(pc)
&& !pconnection_wclosed(pc))
         pconnection_maybe_connect_lh(pc);
@@ -1106,7 +1107,6 @@ static pn_event_batch_t *pconnection_process(pconnection_t *pc, uint32_t
events,
       if (pc->new_events & EPOLLIN)
         pc->read_blocked = false;
     }
-    pc->current_arm = 0;
     pc->new_events = 0;
   }
 
@@ -1227,9 +1227,10 @@ void pconnection_connected_lh(pconnection_t *pc) {
   }
 }
 
+/* multi-address connections may call pconnection_start multiple times with diffferent FDs
 */
 static void pconnection_start(pconnection_t *pc) {
   int efd = pc->psocket.proactor->epollfd;
-  /* Start polling is a no-op if the timer has alread started. */
+  /* Start timer, a no-op if the timer has already started. */
   start_polling(&pc->timer.epoll_io, efd);  // TODO: check for error
 
   /* Get the local socket name now, get the peer name in pconnection_connected */
@@ -1243,7 +1244,7 @@ static void pconnection_start(pconnection_t *pc) {
     pclosefd(pc->psocket.proactor, fd);
   }
   ee->fd = pc->psocket.sockfd;
-  ee->wanted = EPOLLIN | EPOLLOUT;
+  pc->current_arm = ee->wanted = EPOLLIN | EPOLLOUT;
   start_polling(ee, efd);  // TODO: check for error
 }
 


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


Mime
View raw message