qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r1387377 - /qpid/proton/trunk/proton-c/src/driver.c
Date Tue, 18 Sep 2012 21:57:58 GMT
Author: tross
Date: Tue Sep 18 21:57:57 2012
New Revision: 1387377

URL: http://svn.apache.org/viewvc?rev=1387377&view=rev
Log:
PROTON-30 - Temporary driver change to support multi-threading.

Modified:
    qpid/proton/trunk/proton-c/src/driver.c

Modified: qpid/proton/trunk/proton-c/src/driver.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/driver.c?rev=1387377&r1=1387376&r2=1387377&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/driver.c (original)
+++ qpid/proton/trunk/proton-c/src/driver.c Tue Sep 18 21:57:57 2012
@@ -677,11 +677,18 @@ static void pn_driver_rebuild(pn_driver_
   }
 }
 
-void pn_driver_wait(pn_driver_t *d, int timeout) {
+void pn_driver_wait_1(pn_driver_t *d)
+{
   pn_driver_rebuild(d);
+}
 
+void pn_driver_wait_2(pn_driver_t *d, int timeout)
+{
   DIE_IFE(poll(d->fds, d->nfds, d->closed_count > 0 ? 0 : timeout));
+}
 
+void pn_driver_wait_3(pn_driver_t *d)
+{
   if (d->fds[0].revents & POLLIN) {
     //clear the pipe
     char buffer[512];
@@ -712,6 +719,23 @@ void pn_driver_wait(pn_driver_t *d, int 
   d->connector_next = d->connector_head;
 }
 
+//
+// XXX - pn_driver_wait has been divided into three internal functions as a
+//       temporary workaround for a multi-threading problem.  A multi-threaded
+//       application must hold a lock on parts 1 and 3, but not on part 2.
+//       This temporary change, which is not reflected in the driver's API, allows
+//       a multi-threaded application to use the three parts separately.
+//
+//       This workaround will eventually be replaced by a more elegant solution
+//       to the problem.
+//
+void pn_driver_wait(pn_driver_t *d, int timeout)
+{
+    pn_driver_wait_1(d);
+    pn_driver_wait_2(d, timeout);
+    pn_driver_wait_3(d);
+}
+
 pn_listener_t *pn_driver_listener(pn_driver_t *d) {
   if (!d) return NULL;
 



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


Mime
View raw message