mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-05 13:28:00 +02:00
Make colormap private interfaces thread safe.
Protect access to the dpy structure by a display lock, so that these can be called outside of a global display lock. That allows the XCMS colormap functions to be thread safe without having the whole functions within a display lock, to avoid deadlocks. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> See-also: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/215 See-also: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/94 Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/254>
This commit is contained in:
parent
739fce4c12
commit
1472048b7a
1 changed files with 14 additions and 0 deletions
|
|
@ -87,12 +87,17 @@ CmapRecForColormap(
|
||||||
_XAsyncHandler async;
|
_XAsyncHandler async;
|
||||||
_XAsyncErrorState async_state;
|
_XAsyncErrorState async_state;
|
||||||
|
|
||||||
|
LockDisplay(dpy);
|
||||||
for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
|
for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
|
||||||
pRec = pRec->pNext) {
|
pRec = pRec->pNext) {
|
||||||
if (pRec->cmapID == cmap) {
|
if (pRec->cmapID == cmap) {
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
return(pRec);
|
return(pRec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can't find an XcmsCmapRec associated with cmap in our records.
|
* Can't find an XcmsCmapRec associated with cmap in our records.
|
||||||
|
|
@ -258,9 +263,12 @@ _XcmsAddCmapRec(
|
||||||
pNew->dpy = dpy;
|
pNew->dpy = dpy;
|
||||||
pNew->windowID = windowID;
|
pNew->windowID = windowID;
|
||||||
pNew->visual = visual;
|
pNew->visual = visual;
|
||||||
|
LockDisplay(dpy);
|
||||||
pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
|
pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
|
||||||
dpy->cms.clientCmaps = (XPointer)pNew;
|
dpy->cms.clientCmaps = (XPointer)pNew;
|
||||||
dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
|
dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note, we don't create the XcmsCCC for pNew->ccc here because
|
* Note, we don't create the XcmsCCC for pNew->ccc here because
|
||||||
|
|
@ -342,6 +350,7 @@ _XcmsDeleteCmapRec(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search for it in the list */
|
/* search for it in the list */
|
||||||
|
LockDisplay(dpy);
|
||||||
pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
|
pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
|
||||||
while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
|
while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
|
||||||
pPrevPtr = &pRec->pNext;
|
pPrevPtr = &pRec->pNext;
|
||||||
|
|
@ -354,6 +363,8 @@ _XcmsDeleteCmapRec(
|
||||||
*pPrevPtr = pRec->pNext;
|
*pPrevPtr = pRec->pNext;
|
||||||
Xfree(pRec);
|
Xfree(pRec);
|
||||||
}
|
}
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -378,6 +389,7 @@ _XcmsFreeClientCmaps(
|
||||||
{
|
{
|
||||||
XcmsCmapRec *pRecNext, *pRecFree;
|
XcmsCmapRec *pRecNext, *pRecFree;
|
||||||
|
|
||||||
|
LockDisplay(dpy);
|
||||||
pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
|
pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
|
||||||
while (pRecNext != NULL) {
|
while (pRecNext != NULL) {
|
||||||
pRecFree = pRecNext;
|
pRecFree = pRecNext;
|
||||||
|
|
@ -390,6 +402,8 @@ _XcmsFreeClientCmaps(
|
||||||
Xfree(pRecFree);
|
Xfree(pRecFree);
|
||||||
}
|
}
|
||||||
dpy->cms.clientCmaps = (XPointer)NULL;
|
dpy->cms.clientCmaps = (XPointer)NULL;
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue