Move c->out.vec refs out of _xcb_conn_wait up to _xcb_out_flush.
authorJamey Sharp <jamey@minilop.net>
Thu, 9 Mar 2006 08:02:42 +0000 (00:02 -0800)
committerJamey Sharp <jamey@minilop.net>
Thu, 9 Mar 2006 08:02:42 +0000 (00:02 -0800)
src/xcb_conn.c
src/xcb_in.c
src/xcb_out.c
src/xcbint.h

index 0491721..792dfb8 100644 (file)
@@ -198,13 +198,13 @@ void XCBDisconnect(XCBConnection *c)
 
 /* Private interface */
 
-int _xcb_conn_wait(XCBConnection *c, const int should_write, pthread_cond_t *cond)
+int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector, int *count)
 {
     int ret;
     fd_set rfds, wfds;
 
     /* If the thing I should be doing is already being done, wait for it. */
-    if(should_write ? c->out.writing : c->in.reading)
+    if(count ? c->out.writing : c->in.reading)
     {
         pthread_cond_wait(cond, &c->iolock);
         return 1;
@@ -215,7 +215,7 @@ int _xcb_conn_wait(XCBConnection *c, const int should_write, pthread_cond_t *con
     ++c->in.reading;
 
     FD_ZERO(&wfds);
-    if(should_write)
+    if(count)
     {
         FD_SET(c->fd, &wfds);
         ++c->out.writing;
@@ -231,10 +231,10 @@ int _xcb_conn_wait(XCBConnection *c, const int should_write, pthread_cond_t *con
             ret = ret && _xcb_in_read(c);
 
         if(FD_ISSET(c->fd, &wfds))
-            ret = ret && _xcb_out_write(c, &c->out.vec, &c->out.vec_len);
+            ret = ret && _xcb_out_write(c, vector, count);
     }
 
-    if(should_write)
+    if(count)
         --c->out.writing;
     --c->in.reading;
 
index ea851c7..fe9a873 100644 (file)
@@ -269,7 +269,7 @@ void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **
      * wait for one. */
     while(c->in.request_completed < request &&
             !(c->in.request_read == request && c->in.current_reply))
-        if(!_xcb_conn_wait(c, /*should_write*/ 0, &cond))
+        if(!_xcb_conn_wait(c, &cond, 0, 0))
             goto done;
 
     if(c->in.request_read != request)
@@ -329,7 +329,7 @@ XCBGenericEvent *XCBWaitForEvent(XCBConnection *c)
     pthread_mutex_lock(&c->iolock);
     /* get_event returns 0 on empty list. */
     while(!(ret = get_event(c)))
-        if(!_xcb_conn_wait(c, /*should_write*/ 0, &c->in.event_cond))
+        if(!_xcb_conn_wait(c, &c->in.event_cond, 0, 0))
             break;
 
     wake_up_next_reader(c);
index c84a27c..ba60d3f 100644 (file)
@@ -272,7 +272,7 @@ int _xcb_out_flush(XCBConnection *c)
         c->out.queue_len = 0;
     }
     while(ret && c->out.vec_len)
-        ret = _xcb_conn_wait(c, /*should_write*/ 1, &c->out.cond);
+        ret = _xcb_conn_wait(c, &c->out.cond, &c->out.vec, &c->out.vec_len);
     c->out.request_written = c->out.request;
     pthread_cond_broadcast(&c->out.cond);
     return ret;
index e6f540a..a8287e8 100644 (file)
@@ -157,7 +157,7 @@ struct XCBConnection {
     _xcb_xid xid;
 };
 
-int _xcb_conn_wait(XCBConnection *c, const int should_write, pthread_cond_t *cond);
+int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector, int *count);
 
 #ifdef GCC_HAS_VISIBILITY
 #pragma GCC visibility pop