Only _xcb_conn_wait calls _xcb_out_write now, so move it to xcb_conn.c and make it...
authorJamey Sharp <jamey@minilop.net>
Sun, 12 Mar 2006 21:20:29 +0000 (13:20 -0800)
committerJamey Sharp <jamey@minilop.net>
Sun, 12 Mar 2006 21:20:29 +0000 (13:20 -0800)
src/xcb_conn.c
src/xcb_out.c
src/xcbint.h

index 1b3e1a2..2da3150 100644 (file)
@@ -33,6 +33,7 @@
 #include <netinet/in.h>
 #include <sys/select.h>
 #include <sys/fcntl.h>
+#include <errno.h>
 
 #include "xcb.h"
 #include "xcbint.h"
@@ -138,6 +139,34 @@ static int read_setup(XCBConnection *c)
     return 1;
 }
 
+/* precondition: there must be something for us to write. */
+static int write_vec(XCBConnection *c, struct iovec **vector, int *count)
+{
+    int n;
+    assert(!c->out.queue_len);
+    n = writev(c->fd, *vector, *count);
+    if(n < 0 && errno == EAGAIN)
+        return 1;
+    if(n <= 0)
+        return 0;
+
+    for(; *count; --*count, ++*vector)
+    {
+        int cur = (*vector)->iov_len;
+        if(cur > n)
+            cur = n;
+        (*vector)->iov_len -= cur;
+        (*vector)->iov_base = (char *) (*vector)->iov_base + cur;
+        n -= cur;
+        if((*vector)->iov_len)
+            break;
+    }
+    if(!*count)
+        *vector = 0;
+    assert(n == 0);
+    return 1;
+}
+
 /* Public interface */
 
 XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c)
@@ -233,7 +262,7 @@ int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector
             ret = ret && _xcb_in_read(c);
 
         if(FD_ISSET(c->fd, &wfds))
-            ret = ret && _xcb_out_write(c, vector, count);
+            ret = ret && write_vec(c, vector, count);
     }
 
     if(count)
index b0130e7..2b1a434 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <errno.h>
 
 #include "xcb.h"
 #include "xcbext.h"
@@ -224,34 +223,6 @@ void _xcb_out_destroy(_xcb_out *out)
     pthread_mutex_destroy(&out->reqlenlock);
 }
 
-/* precondition: there must be something for us to write. */
-int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count)
-{
-    int n;
-    assert(!c->out.queue_len);
-    n = writev(c->fd, *vector, *count);
-    if(n < 0 && errno == EAGAIN)
-        return 1;
-    if(n <= 0)
-        return 0;
-
-    for(; *count; --*count, ++*vector)
-    {
-        int cur = (*vector)->iov_len;
-        if(cur > n)
-            cur = n;
-        (*vector)->iov_len -= cur;
-        (*vector)->iov_base = (char *) (*vector)->iov_base + cur;
-        n -= cur;
-        if((*vector)->iov_len)
-            break;
-    }
-    if(!*count)
-        *vector = 0;
-    assert(n == 0);
-    return 1;
-}
-
 int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count)
 {
     int ret = 1;
index e90ede2..7b32248 100644 (file)
@@ -74,7 +74,6 @@ typedef struct _xcb_out {
 int _xcb_out_init(_xcb_out *out);
 void _xcb_out_destroy(_xcb_out *out);
 
-int _xcb_out_write(XCBConnection *c, struct iovec **vector, int *count);
 int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count);
 int _xcb_out_flush_to(XCBConnection *c, unsigned int request);