summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xcb_conn.c18
-rw-r--r--src/xcb_in.c16
-rw-r--r--src/xcb_out.c8
-rw-r--r--src/xcbint.h2
4 files changed, 28 insertions, 16 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 9aa7cdf..3d18369 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -97,12 +97,12 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
}
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;
}
@@ -255,6 +255,16 @@ void _xcb_conn_shutdown(xcb_connection_t *c)
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;
@@ -278,7 +288,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
++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);
@@ -287,7 +297,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
_xcb_conn_shutdown(c);
ret = 0;
}
- pthread_mutex_lock(&c->iolock);
+ _xcb_lock_io(c);
if(ret)
{
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 604faab..41764df 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -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)
diff --git a/src/xcb_out.c b/src/xcb_out.c
index 162abd4..74787e3 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -163,7 +163,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
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);
@@ -207,7 +207,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
_xcb_conn_shutdown(c);
request = 0;
}
- pthread_mutex_unlock(&c->iolock);
+ _xcb_unlock_io(c);
return request;
}
@@ -216,9 +216,9 @@ int xcb_flush(xcb_connection_t *c)
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;
}
diff --git a/src/xcbint.h b/src/xcbint.h
index 1a71696..1dc6f93 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -159,6 +159,8 @@ struct xcb_connection_t {
};
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);