Commit Graph

597 Commits

Author SHA1 Message Date
Jamey Sharp 2edfd5c375 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb/libxcb
Apparently I forgot to push these months ago.
2011-03-13 09:33:44 -07:00
Jeremy Huddleston 8c3325f8bb darwin: Don't use poll() when expected to run on darwin10 and prior
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-03-04 12:41:55 -08:00
Peter Harris c2e0236462 Don't try to sizeof(void)
sizeof(void) is a gcc extension, and not portable.

Xorg Bugzilla 31959
http://bugs.freedesktop.org/show_bug.cgi?id=31959
http://lists.freedesktop.org/archives/xcb/2010-May/006039.html

Signed-off-by: Peter Harris <pharris@opentext.com>
Tested-by: Cyril Brulebois <kibi@debian.org>
2011-01-27 15:38:36 -05:00
Vincent Torri 9efced72a3 fix Windows build and installation 2011-01-20 20:46:04 -05:00
Peter Harris 3c58136971 Merge branch 'master' of git://anongit.freedesktop.org/~peterh/libxcb 2010-12-23 13:04:40 -05:00
Jeetu Golani 69b78ced1a Don't validate FD_SETSIZE on Win32
Windows' file handles have never been small or consecutive, so Windows'
select has always been implemented the same way as everyone else's poll.

On Windows, FD_SETSIZE is the size of the poll array, not the maximum
SOCKET number.

Signed-off-by: Peter Harris <git@peter.is-a-geek.org>
2010-12-12 16:48:41 -05:00
Uli Schlachter 8ecd754b16 xcb_take_socket: Document sequence wrap requirements
If lots of requests are send without one causing a reply, xcb can get confused
about the current sequence number of a reply. Document the requirements of an
external socket owner to avoid this problem.

The return_socket callback for xcb_take_socket() originally was supposed to
return the last sequence number used, but the version committed to libxcb never
actually had this signature. This fixes the function's documentation not to
mention this non-existent return value.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-11-27 12:48:27 +01:00
Nick Bowler 5755582444 xcb_auth: Fix memory leak in _xcb_get_auth_info.
If the initial get_peer_sock_name(getpeername ...) succeeds, the
pointer to allocated memory is overwritten by the later call to
get_peer_sock_name(getsockname ...).  Fix that up by freeing
the allocated memory before overwriting the pointer.

Signed-off-by: Nick Bowler <nbowler@draconx.ca>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-11-23 14:58:48 +01:00
Jamey Sharp ed37b08751 xcb_in: Use 64-bit sequence numbers internally everywhere.
Widen sequence numbers on entry to those public APIs that still take
32-bit sequence numbers.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 17:13:45 -07:00
Jamey Sharp 6c8b539c2a xcb_discard_reply: Simplify by re-using poll_for_reply helper.
If you discard a sequence number that has multiple responses already
read, this will do more allocations than necessary. But nobody cares
about ListFontsWithInfo.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 13:19:05 -07:00
Jamey Sharp 3a74b5e7a1 xcb_request_check: Hold the I/O lock while deciding to sync.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 12:37:48 -07:00
Jamey Sharp ee1bc1d28a xcb_send_request: Send all requests using a common internal send_request.
This simplifies the critical section of xcb_send_request and fixes a
couple of subtle bugs:

- It's possible for xcb_send_request to need to issue two sync requests
  before it can issue the real request. Previously, we counted sequence
  numbers as if both were issued, but only one went out on the wire.

- The test for whether to sync at 32-bit sequence number wrap has been
  incorrect since we switched to 64-bit sequence numbers internally.

This change means that if the output queue was already full and the
current request is bigger than the output queue, XCB will do one more
write syscall than it did before. But syncs are rare and small requests
are the norm, so this shouldn't be a measurable difference.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 12:37:23 -07:00
Peter Harris b672d1514c Fix _unserialize of reply headers
This cleans up a number of warnings, and passes the sequence number
through correctly.

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 23:16:33 -04:00
Peter Harris 29cca33b90 Clean up a couple of warnings in xprint
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:32:51 -04:00
Peter Harris 8c1d2021ca Make *_unserialize safe to use on buffers in-place
By calling memmove instead of memcpy, and walking the buffer backward
from the end, *_unserialize is safe to use in-place.

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Peter Harris 28a71c6567 Fix memory leak in _sizeof implemented with _unserialize
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Peter Harris a22909c0f5 Don't emit out-of-module sizeof definitions
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Josh Triplett 1c4717de36 Allow disconnecting connections that are in error state.
In support of this, consolidate the two static error_connection
definitions into one so we don't try to free the static out-of-memory
error_connection.

Commit by Josh Triplett and Jamey Sharp.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-09-19 20:38:06 +02:00
Peter Harris 03bcccb132 Add xkb.* to gitignore
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-10 15:54:56 -04:00
Peter Harris 28d3925800 Merge branch 'gsoc2010' of git://anongit.freedesktop.org/~chr/libxcb 2010-09-08 14:41:52 -04:00
Jamey Sharp f0565e8f06 _xcb_conn_wait: Shut down the connection on unexpected poll() events.
If a client calls close(2) on the connection's file descriptor and then
flushes writes, libxcb causes a hang in the client.

Any flush eventually calls _xcb_out_send() with has the following loop:
   while(ret && *count)
       ret = _xcb_conn_wait(c, &c->out.cond, vector, count);

_xcb_conn_wait(), if built with USE_POLL, gets the POLLNVAL error. It only
checks for POLLIN and POLLOUT though, ignoring the error. Return value is 1,
count is unmodified, leaving us with an endless loop and a client hang.

XTS testcase Xlib3/XConnectionNumber triggers this bug. It creates a display
connection, closes its file descriptor, tries to send a no-op, and then expects
an error.
http://cgit.freedesktop.org/xorg/test/xts/tree/xts5/Xlib3/XConnectionNumber.m

If poll returned POLLHUP or POLLERR, we might see the same result.

If poll returns any event we didn't ask for, this patch causes
_xcb_conn_shutdown() to be invoked and an error returned. This matches the
behaviour if select(2) is used instead of poll(2): select(2) returns -1 and
EBADF for an already closed file descriptor.

I believe this fix both is safe and will handle any similar error. POSIX says
that the only bits poll is permitted to set in revents are those bits that were
set in events, plus POLLHUP, POLLERR, and POLLNVAL. So if we see any flags we
didn't ask for then something has gone wrong.

Patch inspired by earlier proposals from Peter Hutterer and Aaron
Plattner--thanks!

Reported-by: Peter Hutterer <peter.hutterer@who-t.net>
Reported-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Aaron Plattner <aplattner@nvidia.com>
Cc: Peter Hutterer <peter.hutterer@who-t.net>
Cc: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-04 13:39:38 -04:00
Peter Harris 20da10490f Merge branch 'master' of git://github.com/topcat/xcb-win32
Conflicts:
	src/xcb_conn.c
	src/xcb_util.c

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-08-31 18:35:20 -04:00
Aaron Plattner 7f5cfcc2fd xcb_disconnect: call shutdown() to force a disconnect
Fixes the X Test Suite's XCloseDisplay-6 test, which has this (admittedly
ridiculous) behavior:

 1. Create a window w.
 2. Open two display connections, dpy1, and dpy2.
 3. Grab the server using dpy1.
 4. Fork.
 5 (child). XSetProperty on w using dpy2.
 5 (parent). Verify that no event was recieved on dpy1.
 6 (parent). XCloseDisplay(dpy1).
 6 (child). Verify that an event was received on dpy2.

It was failing because at step 6 (child), the server had not actually ungrabbed
yet because the file descriptor for dpy1 was still open in the child process.

Shutting down the socket during XCloseDisplay matches the behavior of non-XCB
Xlib, which calls shutdown() from _X11TransSocketDisconnect.

Thanks to Julien Cristau for noticing this.

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-08-25 21:40:52 -04:00
Jamey Sharp 2040f10a4e xcb_request_check: Sync even if an event was read for this sequence.
This fixes the test case I have so far for Havoc's report that
xcb_request_check hangs.

Rationale: Since we have a void cookie, request_expected can't have been
set equal to this sequence number when the request was sent; it can only
have become equal due to the arrival of an event or error. If it became
equal due to an event then we still need to sync. If it became equal due
to an error, then request_completed will have been updated, which means
we correctly won't sync.

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

However, Havoc reports that he can still reproduce the problem, so we
may be revisiting this later.

Reported-by: Havoc Pennington <hp@pobox.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-08-24 09:29:59 -07:00
Christoph Reimann 5e8a7ade2d small fix to get rid of some compiler warnings
also added very basic documentation for xkb
2010-08-16 20:24:40 +02:00
Christoph Reimann b89f634ff9 small fix in the xkb pkg file 2010-08-16 18:22:42 +02:00
Christoph Reimann 22e1013131 added accessors for special cases
major bugfixes include: rewrite of prefix related functions, merge of serialize/unserialize/... generators, extended field name resolution
2010-08-16 18:19:16 +02:00
Julien Danjou 35f901a0f2 Release libxcb 1.7
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-08-13 13:46:37 +02:00
Christoph Reimann fe0e32b5fa special case 'intermixed variable and fixed size fields': fixed reply side, needs testing 2010-08-08 21:25:13 +02:00
Christoph Reimann 77b594f958 renamed most _unserialize() functions to _sizeof() and fixed _unserialize() for the special case of intermixed variable and fixed size fields 2010-08-05 15:55:28 +02:00
Eamon Walsh dd1a4dbe20 Tutorial uses wrong function.
https://bugs.freedesktop.org/show_bug.cgi?id=29392

Signed-off-by: Eamon Walsh <efw@eamonwalsh.com>
2010-08-05 00:50:22 -04:00
Christoph Reimann b187f029d6 attempt to fix special case: variable fields followed by fixed size fields 2010-08-02 23:30:42 +02:00
Christoph Reimann a700eeb502 bug fixes for all kinds of 'special cases' 2010-08-01 23:40:20 +02:00
Christoph Reimann 1c590d5a86 partial rewrite of serialize helper functions completed;
_serialize() & _unserialize() have been tested for switch derived from valueparam
2010-07-22 16:41:15 +02:00
Christoph Reimann 566ae9baee preliminary handling of further special cases in unserialize
first attempts to unify serialize and unserialize
2010-07-20 22:46:37 +02:00
Christoph Reimann 4e665e1580 added generating code for _serialize() in case of variable sized structs (largely untested) 2010-07-15 18:43:43 +02:00
Christoph Reimann d003145609 xkb: added pkg config file 2010-07-13 20:08:51 +02:00
Christoph Reimann 86704124b1 new and still preliminary functions for switch; feautures include
- API compatibility with valueparam
- request _aux() auxiliary functions
- _serialize() and _unserialize() auxiliary functions
- new data type that allows mixing of fixed and variable size members
2010-07-13 20:06:08 +02:00
Christoph Reimann 80322d1163 xkb: updated configure.ac/Makefile.am 2010-07-13 19:59:23 +02:00
Christoph Reimann 8c2707773b added xcb_sumof() with restriction to uint8_t 2010-07-13 19:56:44 +02:00
Jamey Sharp 496efb7624 _xcb_conn_wait: Fix whitespace.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-07-13 07:10:50 -07:00
Jeremy Huddleston 74057c7eb6 AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
launchd: Explicitly search /sbin

Previously, launchd wasn't found if /sbin wasn't in the user's PATH.
https://bugs.freedesktop.org/show_bug.cgi?id=29028

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-07-12 16:53:53 -07:00
Vincent Torri 75ff427d41 configure.ac: Report which extensions are being built.
I was surprised to see that xinput was not installed. Looking at
configure.ac, it seems that it is disabled by default. Maybe configure
should output the status of the different extensions.
2010-06-20 20:50:06 -07:00
Pauli Nieminen de3cdad87a xcb_connect_to_display_with_auth_info: Fix memory leak
protocol and host are allocated in _xcb_parse_display but ownership of
them is passed to the caller. They have to be freed in
xcb_connect_to_display_with_auth_info.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-06-15 13:16:45 -04:00
Pauli Nieminen 18718d483e _xcb_parse_display: Fix error path
xcb_parse_display claims that there is no side effects when failing.
That requires _xcb_parse_display to free the memory in failure case.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-06-15 13:16:45 -04:00
Jeremy Huddleston 3f79628bec xcb_open: Improve protocol/host parsing
Support scenarios where host is not set and protocol is.  eg:

DISPLAY=tcp/:0

as well as the "inet" and "inet6" alias for "tcp" for compatability
with Xlib

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-14 14:28:53 -07:00
Marcin Kościelnicki e4b746ac13 Add ~ operator support in code generator
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-05-14 13:19:28 +02:00
Arnaud Fontaine 5e86cb0566 Fix GCC error on undeclared variable when not using abstract socket
This is a regression found by tinderbox in previous commit:

xcb_util.c: In function '_xcb_open':
xcb_util.c:213: error: 'fd' undeclared (first use in this function)
2010-04-30 18:49:18 +01:00
Arnaud Fontaine a546d00091 Get rid of PATH_MAX and MAXPATHLEN
There could be no upper limit on the length of a path according
to POSIX, therefore these macros may not be defined at all on
some systems (such as GNU Hurd).

Signed-off-by: Arnaud Fontaine <arnau@debian.org>
Reviewed-by: Peter Harris <pharris@opentext.com>
2010-04-30 14:47:16 +02:00
Jeremy Huddleston d068572173 Use limits.h instead of syslimits.h
Regression found by tinderbox in 89b3485dad

xcb_util.c:31:27: error: sys/syslimits.h: No such file or directory
xcb_util.c: In function '_xcb_open':
xcb_util.c:148: error: 'PATH_MAX' undeclared (first use in this function)

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-23 21:57:26 -07:00