Add xcb_xlib_lock and xcb_xlib_unlock, a special-purpose two-level recursive lock...
[free-sw/xcb/libxcb] / src / xcb_in.c
index 3498684..41764df 100644 (file)
@@ -318,7 +318,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
     if(c->has_error)
         return 0;
 
-    pthread_mutex_lock(&c->iolock);
+    _xcb_lock_io(c);
 
     /* If this request has not been written yet, write it. */
     if(_xcb_out_flush_to(c, request))
@@ -358,7 +358,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
     }
 
     wake_up_next_reader(c);
-    pthread_mutex_unlock(&c->iolock);
+    _xcb_unlock_io(c);
     return ret;
 }
 
@@ -373,9 +373,9 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
         return 1; /* would not block */
     }
     assert(reply != 0);
-    pthread_mutex_lock(&c->iolock);
+    _xcb_lock_io(c);
     ret = poll_for_reply(c, request, reply, error);
-    pthread_mutex_unlock(&c->iolock);
+    _xcb_unlock_io(c);
     return ret;
 }
 
@@ -384,14 +384,14 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
     xcb_generic_event_t *ret;
     if(c->has_error)
         return 0;
-    pthread_mutex_lock(&c->iolock);
+    _xcb_lock_io(c);
     /* get_event returns 0 on empty list. */
     while(!(ret = get_event(c)))
         if(!_xcb_conn_wait(c, &c->in.event_cond, 0, 0))
             break;
 
     wake_up_next_reader(c);
-    pthread_mutex_unlock(&c->iolock);
+    _xcb_unlock_io(c);
     return ret;
 }
 
@@ -401,12 +401,12 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c, int *error)
     {
         xcb_generic_event_t *ret = 0;
         int success;
-        pthread_mutex_lock(&c->iolock);
+        _xcb_lock_io(c);
         /* FIXME: follow X meets Z architecture changes. */
         success = _xcb_in_read(c);
         if(success)
             ret = get_event(c);
-        pthread_mutex_unlock(&c->iolock);
+        _xcb_unlock_io(c);
         if(success)
         {
             if(error)
@@ -427,8 +427,8 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c, int *error)
 xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
 {
     /* FIXME: this could hold the lock to avoid syncing unnecessarily, but
-     * that would require factoring the locking out of xcb_get_input_focus_t,
-     * xcb_get_input_focus_reply_t, and xcb_wait_for_reply_t. */
+     * that would require factoring the locking out of xcb_get_input_focus,
+     * xcb_get_input_focus_reply, and xcb_wait_for_reply. */
     xcb_generic_error_t *ret;
     void *reply;
     if(c->has_error)