}
assert(count <= sizeof(parts) / sizeof(*parts));
- pthread_mutex_lock(&c->iolock);
+ _xcb_lock_io(c);
{
struct iovec *parts_ptr = parts;
ret = _xcb_out_send(c, &parts_ptr, &count);
}
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
return ret;
}
c->has_error = 1;
}
+void _xcb_lock_io(xcb_connection_t *c)
+{
+ pthread_mutex_lock(&c->iolock);
+}
+
+void _xcb_unlock_io(xcb_connection_t *c)
+{
+ pthread_mutex_unlock(&c->iolock);
+}
+
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count)
{
int ret;
++c->out.writing;
}
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
do {
ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
} while (ret == -1 && errno == EINTR);
_xcb_conn_shutdown(c);
ret = 0;
}
- pthread_mutex_lock(&c->iolock);
+ _xcb_lock_io(c);
if(ret)
{
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))
}
wake_up_next_reader(c);
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
return ret;
}
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;
}
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;
}
{
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)
workaround = WORKAROUND_GLX_GET_FB_CONFIGS_BUG;
/* get a sequence number and arrange for delivery. */
- pthread_mutex_lock(&c->iolock);
+ _xcb_lock_io(c);
/* wait for other writing threads to get out of my way. */
while(c->out.writing)
pthread_cond_wait(&c->out.cond, &c->iolock);
_xcb_conn_shutdown(c);
request = 0;
}
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
return request;
}
int ret;
if(c->has_error)
return 0;
- pthread_mutex_lock(&c->iolock);
+ _xcb_lock_io(c);
ret = _xcb_out_flush_to(c, c->out.request);
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
return ret;
}
};
void _xcb_conn_shutdown(xcb_connection_t *c);
+void _xcb_lock_io(xcb_connection_t *c);
+void _xcb_unlock_io(xcb_connection_t *c);
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);