projects
/
free-sw
/
xcb
/
libxcb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Avoid race condition when using multiple make jobs
[free-sw/xcb/libxcb]
/
src
/
xcb_xlib.c
diff --git
a/src/xcb_xlib.c
b/src/xcb_xlib.c
index
8cc6837
..
59f972c
100644
(file)
--- a/
src/xcb_xlib.c
+++ b/
src/xcb_xlib.c
@@
-26,16
+26,30
@@
#include "xcbxlib.h"
#include "xcbint.h"
#include "xcbxlib.h"
#include "xcbint.h"
-unsigned int XCBGetRequestSent(XCBConnection *c)
+#include <assert.h>
+
+unsigned int xcb_get_request_sent(xcb_connection_t *c)
+{
+ if(c->has_error)
+ return 0;
+ return c->out.request;
+}
+
+void xcb_xlib_lock(xcb_connection_t *c)
{
{
-
unsigned int ret
;
-
pthread_mutex_lock(&c->io
lock);
-
ret = c->out.request
;
-
pthread_mutex_unlock(&c->iolock
);
-
return ret
;
+
_xcb_lock_io(c)
;
+
assert(!c->xlib.
lock);
+
c->xlib.lock = 1
;
+
c->xlib.thread = pthread_self(
);
+
_xcb_unlock_io(c)
;
}
}
-
pthread_mutex_t *XCBGetIOLock(XCBConnection
*c)
+
void xcb_xlib_unlock(xcb_connection_t
*c)
{
{
- return &c->iolock;
+ _xcb_lock_io(c);
+ assert(c->xlib.lock);
+ assert(pthread_equal(c->xlib.thread, pthread_self()));
+ c->xlib.lock = 0;
+ pthread_cond_broadcast(&c->xlib.cond);
+ _xcb_unlock_io(c);
}
}