[Xcb-commit] 3 commits - src
Jamey Sharp
jamey at kemper.freedesktop.org
Sat Apr 17 18:21:13 PDT 2010
src/xcb_conn.c | 5 +----
src/xcb_in.c | 28 +++++++++++++---------------
src/xcb_out.c | 16 ++++++++--------
src/xcbint.h | 4 +++-
4 files changed, 25 insertions(+), 28 deletions(-)
New commits:
commit b0525e242368fffbc77ebb45293f34e80847e65a
Author: Jamey Sharp <jamey at minilop.net>
Date: Sat Apr 17 17:59:11 2010 -0700
Always wake up readers after writing.
Since writers must make sure they read as well, threads may have gone to
sleep waiting for the opportunity to read. The writer must wake up one
of those readers or the application can hang.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Reviewed-by: Josh Triplett <josh at freedesktop.org>
diff --git a/src/xcb_in.c b/src/xcb_in.c
index a2f7312..6dd358c 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -69,16 +69,6 @@ typedef struct reader_list {
struct reader_list *next;
} reader_list;
-static void wake_up_next_reader(xcb_connection_t *c)
-{
- int pthreadret;
- if(c->in.readers)
- pthreadret = pthread_cond_signal(c->in.readers->data);
- else
- pthreadret = pthread_cond_signal(&c->in.event_cond);
- assert(pthreadret == 0);
-}
-
static int read_packet(xcb_connection_t *c)
{
xcb_generic_reply_t genrep;
@@ -402,7 +392,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
pthread_cond_destroy(&cond);
}
- wake_up_next_reader(c);
+ _xcb_in_wake_up_next_reader(c);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -545,7 +535,7 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
if(!_xcb_conn_wait(c, &c->in.event_cond, 0, 0))
break;
- wake_up_next_reader(c);
+ _xcb_in_wake_up_next_reader(c);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -629,6 +619,16 @@ void _xcb_in_destroy(_xcb_in *in)
}
}
+void _xcb_in_wake_up_next_reader(xcb_connection_t *c)
+{
+ int pthreadret;
+ if(c->in.readers)
+ pthreadret = pthread_cond_signal(c->in.readers->data);
+ else
+ pthreadret = pthread_cond_signal(&c->in.event_cond);
+ assert(pthreadret == 0);
+}
+
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags)
{
pending_reply *pend = malloc(sizeof(pending_reply));
diff --git a/src/xcb_out.c b/src/xcb_out.c
index afc12c1..fbce7a0 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -338,6 +338,7 @@ int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
c->out.request_written = c->out.request;
pthread_cond_broadcast(&c->out.cond);
+ _xcb_in_wake_up_next_reader(c);
return ret;
}
diff --git a/src/xcbint.h b/src/xcbint.h
index 9d44238..f07add8 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -137,6 +137,8 @@ typedef struct _xcb_in {
int _xcb_in_init(_xcb_in *in);
void _xcb_in_destroy(_xcb_in *in);
+void _xcb_in_wake_up_next_reader(xcb_connection_t *c);
+
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
void _xcb_in_replies_done(xcb_connection_t *c);
commit eff3851ba80c42b5b3ba240f7e9049d7b0fac6f0
Author: Jamey Sharp <jamey at minilop.net>
Date: Sun Mar 28 10:31:55 2010 -0700
Fix strict-aliasing warning when getting generic event length.
xcb_ge_event_t has its length field in the same place that
xcb_generic_reply_t does, so there's no need to cast the generic reply.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Cc: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Julien Danjou <julien at danjou.info>
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 80f5523..a2f7312 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -154,9 +154,7 @@ static int read_packet(xcb_connection_t *c)
/* XGE events may have sizes > 32 */
if (genrep.response_type == XCB_XGE_EVENT)
- {
- eventlength = ((xcb_ge_event_t*)&genrep)->length * 4;
- }
+ eventlength = genrep.length * 4;
buf = malloc(length + eventlength +
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t)));
commit 6dd8228a137d280ce24cec604a419129d8ed0e8e
Author: Jamey Sharp <jamey at minilop.net>
Date: Fri Feb 12 12:25:05 2010 -0800
Delete a useless level of indirection from _xcb_out_send's parameters.
_xcb_out_send needs _xcb_conn_wait to store back its progress so it can
be reinvoked to pick up where it left off---but then _xcb_out_send
guarantees that it leaves either an empty output vector or a shut-down
connection, so *its* callers never care how much progress was made.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Reviewed-by: Josh Triplett <josh at freedesktop.org>
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 1d37614..50a662b 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -102,10 +102,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
pthread_mutex_lock(&c->iolock);
- {
- struct iovec *parts_ptr = parts;
- ret = _xcb_out_send(c, &parts_ptr, &count);
- }
+ ret = _xcb_out_send(c, parts, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
diff --git a/src/xcb_out.c b/src/xcb_out.c
index b3050fe..afc12c1 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -52,7 +52,7 @@ static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
vector[0].iov_base = c->out.queue;
vector[0].iov_len = c->out.queue_len;
c->out.queue_len = 0;
- return _xcb_out_send(c, &vector, &count);
+ return _xcb_out_send(c, vector, count);
}
static void get_socket_back(xcb_connection_t *c)
@@ -283,7 +283,7 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
return 0;
pthread_mutex_lock(&c->iolock);
c->out.request += requests;
- ret = _xcb_out_send(c, &vector, &count);
+ ret = _xcb_out_send(c, vector, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -331,11 +331,11 @@ void _xcb_out_destroy(_xcb_out *out)
pthread_mutex_destroy(&out->reqlenlock);
}
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count)
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
{
int ret = 1;
- while(ret && *count)
- ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
+ while(ret && count)
+ ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
c->out.request_written = c->out.request;
pthread_cond_broadcast(&c->out.cond);
return ret;
@@ -348,12 +348,11 @@ int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
return 1;
if(c->out.queue_len)
{
- struct iovec vec, *vec_ptr = &vec;
- int count = 1;
+ struct iovec vec;
vec.iov_base = c->out.queue;
vec.iov_len = c->out.queue_len;
c->out.queue_len = 0;
- return _xcb_out_send(c, &vec_ptr, &count);
+ return _xcb_out_send(c, &vec, 1);
}
while(c->out.writing)
pthread_cond_wait(&c->out.cond, &c->iolock);
diff --git a/src/xcbint.h b/src/xcbint.h
index 154cca0..9d44238 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -106,7 +106,7 @@ typedef struct _xcb_out {
int _xcb_out_init(_xcb_out *out);
void _xcb_out_destroy(_xcb_out *out);
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
More information about the xcb-commit
mailing list