summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@freedesktop.org>2004-08-31 11:37:03 +0000
committerEgbert Eich <eich@freedesktop.org>2004-08-31 11:37:03 +0000
commit2d3afb68a104a80a21ee622b9abb9c95e83505d3 (patch)
tree98d56bd26998e173fc6b6dc138eb83a9c824cb31
parente689746c8d0e21e9011e8b91a3071d235d3a2a74 (diff)
downloadxorg-lib-libX11-XORG-6_8_1.tar.gz
Fixed some lockups in XIM code when the application is running with multi thread support. These lockups occur deep down in XFilterEvents() which itself locks when another Xlib function gets called that also locks. This fixes two instances by separating those Xlib functions into an internal (non-locking) call and a locking wrapper that is used as an external function. There may be several other such instances therefore another more general patch is eventually required (Bugzilla #1182).XORG-6_8_1
-rw-r--r--include/X11/Xlibint.h9
-rw-r--r--modules/im/ximcp/imDefLkup.c2
-rw-r--r--modules/im/ximcp/imLcFlt.c2
-rw-r--r--src/GetWAttrs.c31
-rw-r--r--src/PutBEvent.c22
5 files changed, 47 insertions, 19 deletions
diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
index c1966ada..4ff7fb6e 100644
--- a/include/X11/Xlibint.h
+++ b/include/X11/Xlibint.h
@@ -1298,6 +1298,15 @@ extern void _XSetClipRectangles (
int n,
int ordering);
+Status _XGetWindowAttributes(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr);
+
+int _XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event);
+
_XFUNCPROTOEND
#endif /* _XLIBINT_H_ */
diff --git a/modules/im/ximcp/imDefLkup.c b/modules/im/ximcp/imDefLkup.c
index 21ddedfe..2baa2fe5 100644
--- a/modules/im/ximcp/imDefLkup.c
+++ b/modules/im/ximcp/imDefLkup.c
@@ -463,7 +463,7 @@ _XimGetWindowEventmask(
Xim im = (Xim )ic->core.im;
XWindowAttributes atr;
- if (!XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
+ if (!_XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
return 0;
return (EVENTMASK)atr.your_event_mask;
}
diff --git a/modules/im/ximcp/imLcFlt.c b/modules/im/ximcp/imLcFlt.c
index 85130137..e038c5f1 100644
--- a/modules/im/ximcp/imLcFlt.c
+++ b/modules/im/ximcp/imLcFlt.c
@@ -73,7 +73,7 @@ _XimLocalFilter(d, w, ev, client_data)
ic->private.local.composed = p;
/* return back to client KeyPressEvent keycode == 0 */
ev->xkey.keycode = 0;
- XPutBackEvent(d, ev);
+ _XPutBackEvent(d, ev);
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
return(True);
diff --git a/src/GetWAttrs.c b/src/GetWAttrs.c
index c5e9d438..527675fc 100644
--- a/src/GetWAttrs.c
+++ b/src/GetWAttrs.c
@@ -24,7 +24,6 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86$ */
#define NEED_REPLIES
#include "Xlibint.h"
@@ -84,10 +83,11 @@ _XWAttrsHandler(
return True;
}
-Status XGetWindowAttributes(dpy, w, attr)
- register Display *dpy;
- Window w;
- XWindowAttributes *attr;
+Status
+_XGetWindowAttributes(
+ register Display *dpy,
+ Window w,
+ XWindowAttributes *attr)
{
xGetGeometryReply rep;
register xResourceReq *req;
@@ -96,7 +96,6 @@ Status XGetWindowAttributes(dpy, w, attr)
_XAsyncHandler async;
_XWAttrsState async_state;
- LockDisplay(dpy);
GetResReq(GetWindowAttributes, w, req);
async_state.attr_seq = dpy->request;
@@ -113,14 +112,10 @@ Status XGetWindowAttributes(dpy, w, attr)
if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
DeqAsyncHandler(dpy, &async);
- UnlockDisplay(dpy);
- SyncHandle();
return (0);
}
DeqAsyncHandler(dpy, &async);
if (!async_state.attr) {
- UnlockDisplay(dpy);
- SyncHandle();
return (0);
}
attr->x = cvtINT16toInt (rep.x);
@@ -138,8 +133,22 @@ Status XGetWindowAttributes(dpy, w, attr)
break;
}
}
+ return(1);
+}
+
+Status
+XGetWindowAttributes(
+ Display *dpy,
+ Window w,
+ XWindowAttributes *attr)
+{
+ Status ret;
+
+ LockDisplay(dpy);
+ ret = _XGetWindowAttributes(dpy, w, attr);
UnlockDisplay(dpy);
SyncHandle();
- return(1);
+
+ return ret;
}
diff --git a/src/PutBEvent.c b/src/PutBEvent.c
index 2260359f..c8499360 100644
--- a/src/PutBEvent.c
+++ b/src/PutBEvent.c
@@ -33,16 +33,14 @@ from The Open Group.
#include "Xlibint.h"
int
-XPutBackEvent (dpy, event)
- register Display *dpy;
- register XEvent *event;
+_XPutBackEvent (
+ register Display *dpy,
+ register XEvent *event)
{
register _XQEvent *qelt;
- LockDisplay(dpy);
if (!dpy->qfree) {
if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
- UnlockDisplay(dpy);
return 0;
}
dpy->qfree->next = NULL;
@@ -56,6 +54,18 @@ XPutBackEvent (dpy, event)
if (dpy->tail == NULL)
dpy->tail = qelt;
dpy->qlen++;
- UnlockDisplay(dpy);
return 0;
}
+
+int
+XPutBackEvent (
+ register Display * dpy,
+ register XEvent *event)
+ {
+ int ret;
+
+ LockDisplay(dpy);
+ ret = _XPutBackEvent(dpy, event);
+ UnlockDisplay(dpy);
+ return ret;
+ }