Submitted By: Dan Nicholson Date: 2007-07-08 Initial Package Version: 1.0 Upstream Status: Will not apply. Origin: OpenSuSE http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/suse/src/xorg-x11-libxcb-7.2-33.src.rpm Description: This is a workaround for X11 applications which have locking bugs that will trigger assertions when libxcb is used. An environment variable, LIBXCB_ALLOW_SLOPPY_LOCK, can be set to skip the check that the display lock has been set correctly. This will not be merged upstream as the XCB developers have decided to be strict in exposing the bugs so they are fixed in the appropriate location. diff -pNur libxcb-1.0.orig/src/xcb_conn.c libxcb-1.0/src/xcb_conn.c --- libxcb-1.0.orig/src/xcb_conn.c 2006-11-21 20:18:48.000000000 -0800 +++ libxcb-1.0/src/xcb_conn.c 2007-07-08 17:29:46.000000000 -0700 @@ -62,6 +62,11 @@ static int set_fd_flags(const int fd) static int _xcb_xlib_init(_xcb_xlib *xlib) { xlib->lock = 0; + xlib->sloppy_lock = 0; + + if (getenv("LIBXCB_ALLOW_SLOPPY_LOCK")) + xlib->sloppy_lock = 1; + pthread_cond_init(&xlib->cond, 0); return 1; } diff -pNur libxcb-1.0.orig/src/xcbint.h libxcb-1.0/src/xcbint.h --- libxcb-1.0.orig/src/xcbint.h 2006-11-20 23:06:29.000000000 -0800 +++ libxcb-1.0/src/xcbint.h 2007-07-08 17:29:46.000000000 -0700 @@ -130,6 +130,7 @@ int _xcb_in_read_block(xcb_connection_t typedef struct _xcb_xlib { int lock; + int sloppy_lock; pthread_t thread; pthread_cond_t cond; } _xcb_xlib; diff -pNur libxcb-1.0.orig/src/xcb_xlib.c libxcb-1.0/src/xcb_xlib.c --- libxcb-1.0.orig/src/xcb_xlib.c 2006-11-02 17:38:00.000000000 -0800 +++ libxcb-1.0/src/xcb_xlib.c 2007-07-08 17:29:46.000000000 -0700 @@ -38,7 +38,8 @@ unsigned int xcb_get_request_sent(xcb_co void xcb_xlib_lock(xcb_connection_t *c) { _xcb_lock_io(c); - assert(!c->xlib.lock); + if (!c->xlib.sloppy_lock) + assert(!c->xlib.lock); c->xlib.lock = 1; c->xlib.thread = pthread_self(); _xcb_unlock_io(c); @@ -47,7 +48,8 @@ void xcb_xlib_lock(xcb_connection_t *c) void xcb_xlib_unlock(xcb_connection_t *c) { _xcb_lock_io(c); - assert(c->xlib.lock); + if (!c->xlib.sloppy_lock) + assert(c->xlib.lock); assert(pthread_equal(c->xlib.thread, pthread_self())); c->xlib.lock = 0; pthread_cond_broadcast(&c->xlib.cond);