mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-03 17:08:09 +02:00
xlib/shm: Wrap the detection of shm with locking
As we access a global error variable, we need to hold a mutex against simultaneous checking of multiple Displays. This should already be true as we hold our display mutex to serialize initialisation, so just add an assertion. As the client may mix use of cairo in one thread with X from another, we need to hold the Display lock and serialise whilst manipulating the low-level state of the Display. Suggested-by: Uli Schlachter <psychon@znc.in> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
1bc9f673b6
commit
ec01c71eca
1 changed files with 6 additions and 0 deletions
|
|
@ -231,6 +231,7 @@ _pqueue_pop (struct pqueue *pq)
|
|||
}
|
||||
|
||||
static cairo_bool_t _x_error_occurred;
|
||||
|
||||
static int
|
||||
_check_error_handler (Display *display,
|
||||
XErrorEvent *event)
|
||||
|
|
@ -263,7 +264,11 @@ can_use_shm (Display *dpy, int *has_pixmap)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
assert (CAIRO_MUTEX_IS_LOCKED (_cairo_xlib_display_mutex));
|
||||
_x_error_occurred = FALSE;
|
||||
|
||||
XLockDisplay (dpy);
|
||||
XSync (dpy, False);
|
||||
old_handler = XSetErrorHandler (_check_error_handler);
|
||||
|
||||
success = XShmAttach (dpy, &shm);
|
||||
|
|
@ -272,6 +277,7 @@ can_use_shm (Display *dpy, int *has_pixmap)
|
|||
|
||||
XSync (dpy, False);
|
||||
XSetErrorHandler (old_handler);
|
||||
XUnlockDisplay (dpy);
|
||||
|
||||
shmctl (shm.shmid, IPC_RMID, NULL);
|
||||
shmdt (shm.shmaddr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue