[Xcb] [PATCH 4/4] xcb_disconnect: cancellation point
Rémi Denis-Courmont
remi at remlab.net
Thu Jan 7 09:25:15 PST 2010
---
src/xcb.h | 2 +-
src/xcb_conn.c | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/xcb.h b/src/xcb.h
index ced755b..7b2a081 100644
--- a/src/xcb.h
+++ b/src/xcb.h
@@ -394,7 +394,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info);
* @param c: The connection.
*
* Closes the file descriptor and frees all memory associated with the
- * connection @c c.
+ * connection @c c. This is a thread cancellation point.
*/
void xcb_disconnect(xcb_connection_t *c);
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 5786f28..efcc8c5 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -255,15 +255,13 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
void xcb_disconnect(xcb_connection_t *c)
{
- int cancel;
+ int fd;
if(c->has_error)
return;
free(c->setup);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel);
- close(c->fd);
- pthread_setcancelstate(cancel, NULL);
+ fd = c->fd;
pthread_mutex_destroy(&c->iolock);
_xcb_in_destroy(&c->in);
@@ -273,6 +271,7 @@ void xcb_disconnect(xcb_connection_t *c)
_xcb_xid_destroy(c);
free(c);
+ close(fd); /* cancellation point after everything is clean */
}
/* Private interface */
--
1.6.6
More information about the Xcb
mailing list