Commit graph

57 commits

Author SHA1 Message Date
Alan Coopersmith
a4a7df0635 XlibInt.c: include headers needed for ioctl(...FIONREAD...) on Solaris
Fixes: commit 5538b3e4ae

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Adam Jackson
5538b3e4ae _XDefaultIOError: Do better at detecting explicit shutdown
Currently, when the X server crashes or a client is disconnected with
XKillClient, you get a somewhat confusing error message from libX11
along the lines of:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 98 requests (40 known processed) with 0 events remaining.

What's happening here is the previous recvmsg has thrown EAGAIN, since
the socket is non-blocking. In this case, check whether the socket has
any more data to read, and if not treat it like EPIPE.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2019-01-16 11:45:34 -05:00
Adam Jackson
6d2cde9633 _XDefaultIOError: Reformat to be less ugly
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-16 11:45:34 -05:00
Alan Coopersmith
6d1dc1f616 Convert main src directory to use reallocarray() 2018-12-08 10:06:42 -08:00
walter harms
2911c39cec Fixes: warning: variable 'req' set but not,used
Fixes: warning: variable 'req' set but not used [-Wunused-but-set-variable]
       by marking req _X_UNUSED
	Solution was discussed on xorg-devel ML
       Peter Hutter, Alan Coopersmith
        Re: [PATCH libX11 3/5] fix: warning: pointer targets in passing argument 2 of '_XSend' differ in signedness [-Wpointer-sign]

Signed-off-by: harms wharms@bfs.de
2017-08-20 21:47:05 +02:00
walter harms
bf82ec0402 mark _XDefaultIOError as no_return
mark _XDefaultIOError as no_return. No one comes back from exit() ...

Signed-off-by: harms wharms@bfs.de
2017-08-20 21:44:26 +02:00
Arthur Huillet
2d20890e7f _XDefaultError: set XlibDisplayIOError flag before calling exit
_XReply isn't reentrant, and it can lead to deadlocks when the default error
handler is called: _XDefaultError calls exit(1). It is called indirectly by
_XReply when a X protocol error comes in that isn't filtered/handled by an
extension or the application. This means that if the application (or one of its
loaded shared libraries such as the NVIDIA OpenGL driver) has registered any
_fini destructor, _fini will get called while still on the call stack of
_XReply. If the destructor interacts with the X server and calls _XReply, it
will hit a deadlock, looping on the following in _XReply:

    ConditionWait(dpy, dpy->xcb->reply_notify);

It is legal for an application to make Xlib calls during _fini, and that is
useful for an OpenGL driver to avoid resource leaks on the X server side, for
example in the dlopen/dlclose case. However, the driver can not readily tell
whether its _fini is being called because Xlib called exit, or for another
reason (dlclose), so it is hard to cleanly work around this issue in the driver.

This change makes it so _XReply effectively becomes a no-op when called after
_XDefaultError was called, as though an XIOError had happened. The dpy
connection isn't broken at that point, but any call to _XReply is going to hang.
This is a bit of a kludge, because the more correct solution would be to make
_XReply reentrant, maybe by broadcasting the reply_notify condition before
calling the default error handler. However, such a change would carry a grater
risk of introducing regressions in Xlib.

This change will drop some valid requests on the floor, but this should not
matter, as it will only do so in the case where the application is dying: X will
clean up after it once exit() is done running. There is the case of
XSetCloseDownMode(RETAIN_PERMANENT), but an application using that and wishing
to clean up resources in _fini would currently be hitting a deadlock, which is
hardly a better situation.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2017-03-07 12:39:51 -08:00
Christian Linhart
a72d2d06c0 fix for Xlib 32-bit request number issues
Make use of the new 64-bit sequence number API in XCB 1.11.1 to avoid
the 32-bit sequence number wrap in libX11.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71338
Signed-off-by: Christian Linhart <chris@demorecorder.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2015-09-21 12:46:55 -04:00
Thomas Klausner
80b9a346b9 Do not return() after exit().
Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-07-19 23:01:05 +02:00
walter harms
0b7fd7dbec Remove redundant null checks before free
This patch removes some redundant null checks before free.
It should not change the code otherwise. Be aware that this
is only the first series.

Signed-off-by: Harms <wharms@bfs,de>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-06-06 17:16:40 -07:00
Alan Coopersmith
321392ded1 Remove unused ETEST & ESZTEST macros from XlibInt.c
Left behind when 15e5eaf628 removed support for building without XCB.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-01-05 10:27:54 -08:00
Kees Cook
54540d7cba libX11: check size of GetReqExtra after XFlush
Two users of GetReqExtra pass arbitrarily sized allocations from the
caller (ModMap and Host). Adjust _XGetRequest() (called by the GetReqExtra
macro) to double-check the requested length and invalidate "req" when
this happens. Users of GetReqExtra passing lengths greater than the Xlib
buffer size (normally 16K) must check "req" and fail gracefully instead
of crashing.

Any callers of GetReqExtra that do not check "req" for NULL
will experience this change, in the pathological case, as a NULL
dereference instead of a buffer overflow. This is an improvement, but
the documentation for GetReqExtra has been updated to reflect the need
to check the value of "req" after the call.

Bug that manifested the problem:
https://bugs.launchpad.net/ubuntu/+source/x11-xserver-utils/+bug/792628

Signed-off-by: Kees Cook <kees@outflux.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-07-22 23:51:38 -07:00
Thomas Klausner
383e2b0d02 Check for symbol existence with #ifdef, not #if
Reviewed-by: Jamey Sharp <jamey@minilop.net>

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-07-08 23:13:14 -07:00
Alan Coopersmith
d38527e25f Remove more unnecessary casts from Xmalloc/calloc calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
ca106eb03e unifdef WORD64
WORD64 seems to have only been defined in <X11/Xmd.h> when building for
CRAY, to handle int being a 64-bit value (ILP64, not LP64) and having
64-bit alignment requirements.

It hadn't been fully supported even before autotooling, as can be
seen by removed code such as:

 #ifdef WORD64
 _XkbWriteCopyData32 Not Implemented Yet for sizeof(int)==8
 #endif

(mostly performed with unifdef, followed by some manual cleanup of
 the remaining code)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-03-03 18:20:34 -08:00
Alan Coopersmith
b687440c28 Convert more sprintf calls to snprintf
You could analyze most of these and quickly recognize that there was no
chance of buffer overflow already, but why make everyone spend time doing
that when we can just make it obviously safe?

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-02-16 10:42:23 -08:00
Alan Coopersmith
f0b171c8ea Preserve constness in casting arguments through the Data*() routines
Casts were annoying gcc by dropping constness when changing types,
when routines simply either copy data into the request buffer or
send it directly to the X server, and never modify the input.

Fixes gcc warnings including:
ChProp.c: In function 'XChangeProperty':
ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
ChProp.c:83:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetHints.c: In function 'XSetStandardProperties':
SetHints.c:262:20: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetPntMap.c: In function 'XSetPointerMapping':
SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StBytes.c: In function 'XStoreBuffer':
StBytes.c:97:33: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StName.c: In function 'XStoreName':
StName.c:40:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
StName.c: In function 'XSetIconName':
StName.c:51:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-02-16 10:20:53 -08:00
Peter Hutterer
52e1b5cc3b Typo fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-30 16:37:01 +10:00
Peter Hutterer
4a060f993b Add _XGetRequest as substitute for GetReq/GetReqExtra
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-11-08 07:24:07 +10:00
Jamey Sharp
83e1ba59c4 Call _XErrorFunction without holding the Display lock.
Historically, Xlib dropped the Display lock around the upcall to any
user-supplied _XErrorFunction, but somewhere along the way I quit doing
that if you built with XCB. The reasons are lost somewhere in the
pre-git history of Xlib/XCB, and I can't now see any reason to hold the
lock.

The documentation for XSetErrorHandler still applies though:

    Because this condition is not assumed to be fatal, it is acceptable
    for your error handler to return; the returned value is ignored.
    However, the error handler should not call any functions (directly
    or indirectly) on the display that will generate protocol requests
    or that will look for input events.

So while you are now once again permitted to re-enter Xlib from the
error handler, you're only allowed to call non-protocol functions.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-03-15 16:48:07 -07:00
Erkki Seppälä
450e17422c XlibInt: Use strncpy+zero termination instead of strcpy to enforce buffer size
Possible overrun of 8192 byte fixed size buffer "buffer" by copying
"ext->name" without length checking

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-02-01 23:47:18 -08:00
Ander Conselvan de Oliveira
2ace8d5c89 XlibInt: info_list->watch_data was reallocated, but result was discarded
info_list->watch_data was being reallocated, but the return value of
the reallocation was stored only into a local variable. This might
cause some funky behavior and crashes.

Variable "wd_array" goes out of scope
Value "wd_array" is overwritten in "wd_array = (XPointer*)realloc((char*)info_list->watch_data, (((dpy->watcher_count + 1) * 4U == 0U) ? 1U : ((dpy->watcher_count + 1) * 4U)))"

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-02-01 23:46:40 -08:00
Erkki Seppälä
59da8a211e Using freed pointer "e"
Reordered code to first to do the comparison and then to release data

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2011-01-31 11:23:13 +02:00
Pauli Nieminen
92fa96451a Initialize event type
If we receive unsupported event closing connection triggers valgrind
error.

==12017== Conditional jump or move depends on uninitialised value(s)
==12017==    at 0x487D454: _XFreeDisplayStructure (OpenDis.c:607)
==12017==    by 0x486857B: XCloseDisplay (ClDisplay.c:72)
*snip*
==12017==  Uninitialised value was created by a heap allocation
==12017==    at 0x4834C48: malloc (vg_replace_malloc.c:236)
==12017==    by 0x4894147: _XEnq (XlibInt.c:877)
==12017==    by 0x4891BF3: handle_response (xcb_io.c:335)
==12017==    by 0x4892263: _XReply (xcb_io.c:626)
*snip*

Problem is that XFreeDisplaySturture is checking for qelt->event.type ==
GenericEvent while _XUnknownWireEvent doesn't store the type.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
2011-01-03 12:28:19 -05:00
Fernando Carrijo
6de368c9aa Purge macros NEED_EVENTS and NEED_REPLIES
Signed-off-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Acked-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-07-07 15:12:34 -07:00
Josh Triplett
15e5eaf628 Remove support for building without XCB
And there was much rejoicing.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Jamey Sharp <jamey@minilop.net>

Consensus on #xorg-devel agrees with removing --without-xcb; in
particular, acks from Adam Jackson, Daniel Stone, Kristian Høgsberg,
Julien Cristau, and Rémi Cardona.
2010-06-03 22:19:14 -07:00
Jamey Sharp
fd82552d5c Merge branch 'xlib-xcb-thread-fixes' 2010-05-10 16:51:24 -07:00
Jeremy Huddleston
d232b259c3 Fix various build warnings
imLcIm.c: In function '_XimCachedFileName':
imLcIm.c:361: warning: format '%03x' expects type 'unsigned int', but argument 8 has type 'long unsigned int'
imLcIm.c:364: warning: format '%03x' expects type 'unsigned int', but argument 8 has type 'long unsigned int'

imRm.c: In function '_XimDefaultArea':
imRm.c:597: warning: cast from pointer to integer of different size
imRm.c: In function '_XimDefaultColormap':
imRm.c:626: warning: cast from pointer to integer of different size

lcFile.c:224: warning: no previous prototype for 'xlocaledir'

lcUTF8.c: In function 'iconv_cstombs':
lcUTF8.c:1841: warning: assignment discards qualifiers from pointer target type
lcUTF8.c:1869: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c:1873: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c: In function 'iconv_mbstocs':
lcUTF8.c:1935: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_mbtocs':
lcUTF8.c:2031: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_mbstostr':
lcUTF8.c:2121: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_strtombs':
lcUTF8.c:2180: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c: In function '_XlcAddGB18030LocaleConverters':
lcUTF8.c:2367: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2368: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2373: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2374: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2375: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2376: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2377: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type

XlibInt.c: In function '_XGetHostname':
XlibInt.c:3441: warning: implicit declaration of function 'gethostname'
XlibInt.c:3441: warning: nested extern declaration of 'gethostname'

ConnDis.c: In function '_XDisconnectDisplay':
ConnDis.c:540: warning: old-style function definition
ConnDis.c: In function '_XSendClientPrefix':
ConnDis.c:554: warning: old-style function definition
ConnDis.c: In function 'XSetAuthorization':
ConnDis.c:677: warning: old-style function definition

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-23 15:52:51 -07:00
Jamey Sharp
aab43278ae Use InternalLockDisplay on code paths called from LockDisplay.
It's easier to reason about the code when we can't re-enter the
Xlib-private sync-handlers while they're already running.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2010-04-18 01:28:38 -07:00
Josh Triplett
a3f5f1b909 Stop returning an int from _XIDHandler and _XSeqSyncFunction
_XIDHandler and _XSeqSyncFunction originally ran from dpy->synchandler, and
thus had to return an int.  Now, they only run from _XPrivSyncHandler or
LockDisplay, neither of which needs to check their return value since they
always returned 0.  Make them both void.

Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-04-15 14:24:21 -07:00
Jamey Sharp
a6d974dc59 Move XID and sync handling from SyncHandle to LockDisplay to fix races.
XID and sync handling happened via _XPrivSyncHandler, assigned to
dpy->synchandler and called from SyncHandle.  _XPrivSyncHandler thus ran
without the Display lock, so manipulating the Display caused races, and
these races led to assertions in multithreaded code (demonstrated via
ico).

In the XTHREADS case, after you've called XInitThreads, we can hook
LockDisplay and UnlockDisplay.  Use that to run _XIDHandler and
_XSeqSyncHandler from LockDisplay rather than SyncHandle; we then know
that we hold the lock, and thus we can avoid races.  We think it makes
sense to do these both from LockDisplay rather than UnlockDisplay, so
that you know you have valid sync and a valid XID before you start
setting up the request you locked to prepare.

In the !XTHREADS case, or if you haven't called XInitThreads, you don't
get to use Xlib from multiple threads, so we can use the logic we have
now (with synchandler and savedsynchandler) without any concern about
races.

This approach gets a bit exciting when the XID and sequence sync
handlers drop and re-acquire the Display lock. Reacquisition will re-run
the handlers, but they return immediately unless they have work to do,
so they can't recurse more than once.  In the worst case, if both of
them have work to do, we can nest the Display lock three deep.  In the
case of the _XIDHandler, we drop the lock to call xcb_generate_id, which
takes the socket back if it needs to request more XIDs, and taking the
socket back will reacquire the lock; we take care to avoid letting
_XIDHandler run again and re-enter XCB from the return_socket callback
(which causes Very Bad Things, and is Not Allowed).

Tested with ico (with 1 and 20 threads), and with several test programs
for XID and sequence sync.  Tested with and without XInitThreads(), and
with and without XCB.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=23192

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2010-04-15 13:05:08 -07:00
Jamey Sharp
75ea8c3793 Run the user's synchandler as well as any internal synchandlers.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=27595

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-04-12 11:30:20 -07:00
Alan Coopersmith
ddb1786720 Purge CVS/RCS id tags
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2010-01-14 17:38:26 -08:00
Peter Hutterer
bc06d49e9d Fix compiler warning 'unused variable qelt'
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-29 08:44:11 +10:00
Peter Hutterer
554f755e55 Add generic event cookie handling to libX11.
Generic events require more bytes than Xlib provides in the standard XEvent.
Memory allocated by the extension and stored as pointers inside the event is
prone to leak by simple 'while (1) { XNextEvent(...); }' loops.

This patch adds cookie handling for generic events. Extensions may register
a cookie handler in addition to the normal event vectors. If an extension
has registered a cookie handler, _all_ generic events for this extensions
must be handled through cookies. Otherwise, the default event handler is
used.

The cookie handler must return an XGenericEventCookie with a pointer to the
data.The rest of the event (type, serialNumber, etc.) are to be filled as
normal. When a client retrieves such a cookie event, the data is stored in
an internal queue (the 'cookiejar'). This data is freed on the next call to
XNextEvent().

New extension interfaces:
    XESetWireToEventCookie(display, extension_number, cookie_handler)

Where cookie_handler must set cookie->data. The data pointer is of arbitray
size and type but must be a single memory block. This memory block
represents the actual extension's event.

New client interfaces:
    XGetEventData(display, *cookie);
    XFreeEventData(display, *cookie);

If the client needs the actual event data, it must call XGetEventData() with
the cookie. This returns the data pointer (and removes it from the cookie
jar) and the client is then responsible for freeing the event with
XFreeEventData(). It is safe to call either function with a non-cookie
event. Events unclaimed or not handled by the XGetEventData() are cleaned up
automatically.

Example client code:
    XEvent event;
    XGenericEventCookie *cookie = &ev;

    XNextEvent(display, &event);
    if (XGetEventData(display, cookie)) {
        XIEvent *xievent = cookie->data;
        ...
    } else if (cookie->type == GenericEvent) {
        /* handle generic event */
    } else {
        /* handle extension/core event */
    }
    XFreeEventData(display, cookie);

Cookies are not multi-threading safe. Clients that use XGetEventData() must
lock between XNextEvent and XGetEventData to avoid other threads freeing
cookies.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-12 16:09:57 +10:00
Alan Coopersmith
38f9054554 Drop ancient USG SysV #ifdefs
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2009-06-16 08:21:52 -07:00
Alan Coopersmith
c8c4161491 Fix a several sparse warnings: Using plain integer as NULL pointer
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2009-04-06 16:52:46 -07:00
Alan Coopersmith
501f4e0ada Bug 6820: Xlib shouldn't handle EAGAIN as a fatal IO error
X.Org Bug #6820 <http://bugs.freedesktop.org/show_bug.cgi?id=6820>
Patch #17637 <http://bugs.freedesktop.org/attachment.cgi?id=17637>

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
2009-03-12 17:38:21 -07:00
Paulo Cesar Pereira de Andrade
537eb52fe2 WORD64 compile fix. This bug catched on a overview of the code.
The code is wrong since the first git revision, so it seens that it has
not been compiled with WORD64 for quite some time, there is also another
interesting code in xkb/XKBRdBuf.c:
  <hash>ifdef WORD64
  _XkbWriteCopyData32 Not Implemented Yet for sizeof(int)==8
  <hash>endif
and possibly there are other similar problems.
2009-02-02 16:29:27 -02:00
Paulo Cesar Pereira de Andrade
8ba0ca32a6 Janitor: ansification, make distcheck, compiler warnings.
Only convert to use "ansi prototypes" the functions warned from
compilation with "./autogen.sh --prefix=/usr", on a Linux computer.

  Also, only address "trivial" compiler warning fixes in this commit.

  The new .gitignore is the output of a command like:
% find . -name .gitignore -exec cat {} \; | sort | uniq
and only the toplevel .gitignore file was kept.
2009-01-28 20:31:42 -02:00
Jamey Sharp
e6a7b70cdb Support multiple independent internal sync handlers
Xlib has several independent tasks that need to be performed with the
display unlocked. It does this by replacing the existing sync handler with
one of a variety of internal sync handlers. However, if multiple internal
sync handlers need to run, then the last one registering wins and
previously registered internal sync handlers are never invoked. This
manifested as a bug with DRI applications on Xlib/XCB as that requires
both an XID handler after every XID allocation, and the periodic sequence
number handler. The XID handler would win, and the sequence number handler
would never be invoked.

Fix this by unifying the internal sync handler mechanism into a single
function that calls all of the known internal sync handlers. They all need
to deal with being called when not strictly necessary now.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2008-11-04 08:54:01 -08:00
Alan Coopersmith
cf49e53701 Strip whitespace from end of lines in source files 2008-06-17 14:41:17 -07:00
Peter Hutterer
c34f76f475 Pull down extra bytes when reading a GenericEvent (non-xcb).
I refuse to take any responsibily for this code. It works, I guess.
But - all the flushing is done somewhere before that, so we might need to
flush here. Under some circumstances anyway. Don't ask me, I'm an optical
illusion.

Build with xcb as transport layer highly recommended.
2008-05-12 21:48:12 +09:30
Josh Triplett
64325f38ba Fix fd.o bug 15023: make Xlib sync correctly given many void requests
If given many requests without replies, Xlib may not sync until it flushes
the output buffer.  Thus, if Xlib can fit enough requests in the buffer to
pass by the number of requests it would normally sync after (65536 -
BUFSIZE/sizeof(xReq)), it will sync too late.  The test case in bug 15023
demonstrated this by issuing a request with a reply (ListExtensions) at
just the right time to get confused with the GetInputFocus reply issued in
response to the sync 65,536 requests later; the test case used an async
handler to watch the replies, since otherwise it could not issue a request
without waiting for the response.  When the test case failed, Xlib's sync
handler would eat the ListExtensions reply, and the test case's async
handler would see the GetInputFocus reply.

Fix this by replacing SEQLIMIT with a function sync_hazard() that uses the
buffer size to figure out when the sequence numbers could potentially wrap
before the next flush.

With this commit, the test case consistently passed, and the async reply
handler always saw the ListExtensions reply.

Commit by Jamey Sharp and Josh Triplett.
2008-03-15 13:04:54 -07:00
Jamey Sharp
95523387d6 Allow re-entrant Xlib calls from _XIOError.
Some libraries try to clean up X resources from atexit handlers, _fini,
or C++ destructors. To make these work, the Display lock should be
downgraded to a user lock (as in XLockDisplay) before calling exit(3).
This blocks Xlib calls from threads other than the one calling exit(3)
while still allowing the exit handlers to call Xlib.

This assumes that the thread calling exit will call any atexit handlers.
If this does not hold, then an alternate solution would involve
registering an atexit handler to take over the lock, which would only
assume that the same thread calls all the atexit handlers.

Commit by Josh Triplett and Jamey Sharp.
2007-06-02 11:57:39 -07:00
Tilman Sauerbeck
1c75a94790 Bug #10475: Fixed lots of char*/const char* mixups.
I didn't fix all of them, as that would require touching
public headers.
2007-04-06 11:59:31 +02:00
Matthias Hopf
9354351fcb Bug #3104: Compose table cache for faster X11 application starts. Part 1: Pointerless compose data structure, using indices instead of pointers, needed for mmap()ing data structure. 2006-06-16 16:31:37 +02:00
Jamey Sharp
a11d1b0ae6 Use the full_sequence from XCBGenericError/Event for setting last_request_read, and quit replacing _XSetLastRequestRead with an XCB-specific version. 2006-03-03 01:42:49 -08:00
Jamey Sharp
c7cda56eeb Land XCB support on X.org HEAD. 2006-02-19 11:49:15 -08:00
Jamey Sharp
6b0158dfad Refactor _XFlush and _XSend code that sets dpy->synchandler to _XSeqSyncFunction into a new function, _XSetSeqSyncFunction. It makes the patch for XCB cleaner, but is arguably a good idea anyway. 2006-02-14 19:37:36 +00:00