Commit Graph

666 Commits

Author SHA1 Message Date
Daniel Martin 0289348f2c c_client.py: Do not create pointers in unions
Do not create pointers in unions for fields of variadic length.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
2013-08-15 00:34:26 +02:00
Daniel Martin b9efd2a09a c_client.py: Always initialize xcb_align_to
to get rid of:
    warning: 'xcb_align_to' may be used uninitialized in this function

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
2013-08-15 00:34:21 +02:00
Alan Coopersmith 5648ddd2b9 Define _xcb_map_new with explicit void arg list instead of empty one
Fixes Solaris Studio compiler warning:
"xcb_list.c", line 50: warning: old style function definition

and gcc warning:
xcb_list.c: In function '_xcb_map_new':
xcb_list.c:50:11: warning: old-style function definition [-Wold-style-definition]

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2013-08-06 11:10:01 -07:00
Alan Coopersmith cb51f271b2 Enable warnings for pre-C89 style definitions for gcc & Solaris Studio
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2013-08-06 11:09:56 -07:00
Michael Stapelberg bc6a4f557f Build xcb-xkb by default
There have not been any big issues with xcb-xkb recently.

Also, Wayland is using xcb-xkb actively, making distributions compile
libxcb with xkb support anyway, so let’s reflect reality :).

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
2013-08-06 18:46:43 +02:00
Daniel Martin 45619dc71e c_client.py: Inject full_sequence into GE events
The generic event structure xcb_ge_event_t has the full_sequence field
at the 32byte boundary. That's why we've to inject this field into GE
events while generating the structure for them. Otherwise we would read
garbage (the internal full_sequence) when accessing normal event fields
there.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2013-07-12 15:56:14 -04:00
Alan Coopersmith a1e67b141a Fix "indention" typos in xcb-examples.3 man page
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-07-08 17:54:35 -07:00
Marc Deslauriers 8b6bb1a719 Update Makefile.am for newer automake
Debian Bug #710344

Reviewed-by: Daniel Martin <consume.noise@gmail.com>
2013-07-03 19:11:08 -04:00
Christian König 9ae84ad187 fix deadlock with xcb_take_socket/return_socket v3
To prevent different threads from stealing the socket from each other the
caller of "xcb_take_socket" must hold a lock that is also acquired in
"return_socket". Unfortunately xcb tries to prevent calling return_socket
from multiple threads and this can lead to a deadlock situation.

A simple example:
- X11 has taken the socket
- Thread A has locked the display.
- Thread B does xcb_no_operation() and thus ends up in libX11's return_socket(),
  waiting for the display lock.
- Thread A calls e.g. xcb_no_operation(), too, ends up in return_socket() and
  because socket_moving == 1, ends up waiting for thread B
=> Deadlock

This patch allows calling return_socket from different threads at the same time
an so resolves the deadlock situation.

Partially fixes: https://bugs.freedesktop.org/show_bug.cgi?id=20708

v2: fixes additional pthread_cond_wait dependencies,
    rework comments and patch description

v3: separate pthread_cond_wait dependencies and unrelated whitespace
    change into their own patch, use unsigned for socket_seq

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-06-01 22:28:50 +02:00
Alan Coopersmith 1b33867fa9 integer overflow in read_packet() [CVE-2013-2064]
Ensure that when calculating the size of the incoming response from the
Xserver, we don't overflow the integer used in the calculations when we
multiply the int32_t length by 4 and add it to the default response size.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-23 08:12:13 -07:00
Daniel Martin e602b653c1 c_client.py: Handle multiple expr. in a bitcase
Adopt a change from xcbgen. With that modification the expression in a
bitcase became a list of expressions to support multiple <enumref> in a
<bitcase>.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2013-05-23 10:52:05 -04:00
Christian König 6b6044cb8a whitespace fix in xcb_take_socket
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2013-05-15 15:10:22 -07:00
Colin Walters 0dd8f8d26a autogen.sh: Implement GNOME Build API
http://people.gnome.org/~walters/docs/build-api.txt

Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-01-16 13:20:49 -05:00
Chí-Thanh Christopher Nguyễn 76a2166de9 c_client.py: Fix python-3 invalid except statement
Replace except statement with a PEP-3110 compliant one. This fixes a regression
introduced by c3deeaf714
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-10 19:45:25 +01:00
Chí-Thanh Christopher Nguyễn 9db4517c87 c-client.py: Fix python-3 AttributeError: 'dict' object has no attribute 'iteritems'
This fixes a regression introduced by ea71d7d7e3
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-10 19:45:13 +01:00
Uli Schlachter 4ffe54f690 Release libxcb 1.9
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-05 14:53:37 +02:00
Uli Schlachter 4f52f884f4 Include static man pages in "make dist"
This was found by distcheck. It tried to install src/man/xcb-examples.3 and
src/man/xcb-requests.3, but those files weren't in the distribution.

Fix this by explicitly telling automake to distribute those files.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-05 11:23:26 +02:00
Uli Schlachter 23911a707b Fix a multi-thread deadlock
This fixes a deadlock which was seen in-the-wild with wine.

It could happen that two threads tried to read from the socket at the same time
and one of the thread got stuck inside of poll()/select().

The fix works by making sure that the writing thread doesn't steal the reading
thread's reply.

Debugged-by: Erich Hoover <ehoover@mines.edu>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54671
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-30 10:10:18 +02:00
Uli Schlachter c16cc5467e Add a .gitignore for src/man/
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-25 12:31:53 +02:00
Peter Harris 08cc068ead Allow xcb_send_request with >MAX_IOV iovecs
This allows an application to do a scatter/gather operation on a large
image buffer to avoid the extra memcpy.

Use autoconf to use UIO_MAXIOV where IOV_MAX is not available (and the
POSIX minimum of 16 where neither are available).

Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>
2012-09-18 11:42:23 -04:00
Alan Coopersmith ff53285ae3 Return connection failure if display string specifies non-existent screen
Matches the behaviour of Xlib - if you set DISPLAY to :0.1 but only have
one screen, closes connection and returns error.

This introduces a new connection error code:
XCB_CONN_CLOSED_INVALID_SCREEN

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2012-08-29 22:00:55 -07:00
Alan Coopersmith 90889794ad Add AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality
Copied from libX11 configure.ac

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-25 12:34:25 -07:00
Alan Coopersmith b52790e8ed Always include "config.h" at the start of all C source files.
Allows configure to set defines such as _POSIX_SOURCE in config.h
that affect functions exposed by system headers and get consistent
results across all the source files.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-25 12:34:24 -07:00
Alan Coopersmith ed93a6a2a8 Fix "sppported" typo in doxygen comment for XCB_CONN_CLOSED_EXT_NOTSUPPORTED
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-25 12:34:24 -07:00
Colin Walters c3deeaf714 c_client: Fix parallel-make issue creating 'man' directory
With make -j, it was possible to hit a race condition in the code to
make the 'man' directory.

Signed-off-by: Julien Danjou <julien@danjou.info>
2012-08-14 13:33:01 +02:00
Jeremy Huddleston 5f8f2ba1c4 xcb_connect: launchd: Don't fall back on tcp if $DISPLAY is a path to a launchd socket
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-04-21 22:42:51 -07:00
Julien Danjou 71a295082e Move static man to man
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:10:59 +02:00
Julien Danjou df217bf7c9 Do not list manpages, use a wildcard
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:10:15 +02:00
Julien Danjou a4417b1611 Split manpage list in two (static/built)
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:06:54 +02:00
Julien Danjou cc7fab2d5e Allow undocumented code to be built
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-26 18:29:35 +02:00
Michael Stapelberg ea71d7d7e3 c_client.py: generate manpages
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-26 18:23:56 +02:00
Julien Danjou 57a62e99b1 Release libxcb 1.8.1
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-09 15:38:56 +01:00
Uli Schlachter 236f914ea7 Fix a busy loop on BSD and Mac OS
On FreeBSD MSG_WAITALL on a non-blocking socket fails immediately if less bytes
than were asked for are available. This is different than the behavior on linux
where as many bytes as are available are returned in this case. Other OS
apparently follow the FreeBSD behavior.

_xcb_in_read() is used to fill xcb's read buffer, thus this function will call
recv() with a big length argument (xcb's read buffer is by default 16 KiB
large). That many bytes are highly unlikely to be available in the kernel
buffer.

This means that _xcb_in_read() always failed on FreeBSD. Since the socket was
still signaled as readable by poll(), this bug even resulted in a busy loop.

The same issue is present in read_block(), but here it is slightly different.
read_block() is called when we read the first few bytes of an event or a reply,
so that we already know its length. This means that we should be able to use
MSG_WAITALL here, because we know how many bytes there have to be.

However, that function could busy loop, too, when only the first few bytes of
the packet were sent while the rest is stuck somewhere on the way to us. Thus,
MSG_WAITALL should be removed here, too.

Thanks to Christoph Egger from Debian for noticing the problem, doing all the
necessary debugging and figuring out what the problem was! This patch is 99%
from debian. Thanks for all the work.

This bug was introduced in commit 2dcf8b025b.

This commit also reverts commit 9061ee45b8.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2012-03-08 15:40:35 +01:00
Jeremy Huddleston 9061ee45b8 darwin: Use read(2) rather than recv(2)
2dcf8b025b was causing some regressions on
darwin, so go back to using read(2) there until I have time to investigate
further.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-08 00:50:13 -08:00
Julien Cristau 7d235c62f0 Fallback to TCP if no protocol is specified and the UNIX connection fails
Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2012-02-19 14:41:17 -08:00
Arnaud Fontaine f7bd139616 Add xkb_internals and xkb_issues to EXTRA_DIST. 2012-02-10 17:51:09 +09:00
Jon TURNEY 68d30adde9 Update use of error_connection under WIN32 to _xcb_conn_ret_error()
Unfortunately, commit 31b57676 adding WSACleanup/WSAShutdown on Win32 adds a new use
of error_connection, which was removed in commit 769acff0, applied 5 minutes earlier.

src/xcb_util.c: In function 'xcb_connect_to_display_with_auth_info':
src/xcb_util.c:433:39: error: 'error_connection' undeclared (first use in this function)

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Arvind Umrao <arvind.umrao@oracle.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-02-09 23:05:10 +01:00
Jon TURNEY 87b7bf875e Fix build of xcb_auth.c with XDMCP on WIN32
Fix a redefinition problem which shows up when building for _WIN32 and
libXdmcp is installed, so HASXDMAUTH is enabled

It seems this is a special place in xcb as it uses other X11 library headers here

If HASXDMAUTH is defined, include the wrapped windows.h before any header which
includes it unwrapped, to avoid conflicts with types defined in X headers

We need to include config.h and check HASXDMAUTH to avoid an unconditional dependency
on x11proto headers

In file included from install/include/X11/Xdmcp.h:19:0,
                 from git/xcb/libxcb/src/xcb_auth.c:52:
install/include/X11/Xmd.h:120:14: error: conflicting types for 'INT32'
/usr/i686-pc-mingw32/sys-root/mingw/include/basetsd.h:54:13: note: previous declaration of 'INT32' was here
install/include/X11/Xmd.h:143:15: error: conflicting types for 'BOOL'
/usr/i686-pc-mingw32/sys-root/mingw/include/windef.h:234:17: note: previous declaration of 'BOOL' was here

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-01-28 12:44:17 -08:00
Jeremy Huddleston 6db1a2686f Revert "Fix include order with Xdmcp on WIN32"
This reverts commit 0e9246def5.

This change caused build failures because <X11/Xdmcp.h> was never
included under any circumstance.  This is because the check for
HASXDMAUTH was moved before the inclusion of config.h (via xcbint.h)
which defined it.

Found-by: Tinderbox
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-01-28 12:44:06 -08:00
Julien Danjou da1d15082b Bump xcb-proto requirement
We are now unable to build xcb-proto before 1.7.

Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-12 10:25:07 +01:00
Julien Danjou b95b33e8c0 Release libxcb 1.8
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 18:27:38 +01:00
Ryan Pavlik 31b57676e8 Use WSAStartup()/WSACleanup() on WIN32
The alternative is to use these in every WIN32 application which uses xcb. Doing
it this way should be safe, as, according to MSDN, "There must be a call to
WSACleanup for each successful call to WSAStartup. Only the final WSACleanup
function call performs the actual cleanup. The preceding calls simply decrement
an internal reference count"

(We should probably also include ws2_32 in Libs.private for libxcb, as anything
which links with libxcb will also need that, but there seems to be some pkg-config
issues to resolve first...)

v2: Check for errors so WSAStartup()/WSACleanup() uses are balanced
v3: Use same indentation style as surrounding code

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 18:07:12 +01:00
Ryan Pavlik 0e9246def5 Fix include order with Xdmcp on WIN32
Fix a redefinition problem due to include order which shows up when
building for _WIN32 and libXdmcp is installed, so HASXDMAUTH is enabled

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 18:03:31 +01:00
Jon TURNEY 4aa7a2c849 Fix WIN32 compilation after commit 163c47bdc0
WIN32 does not have arpa/inet.h, so do not try to include it unless _WIN32 is
not defined

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 18:03:10 +01:00
Arvind Umrao 769acff0da Added more error states and removed global error_connection
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=41443
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=42304

I have added more xcb connection error states at xcb.h header.
Also I have removed global error_connection variable, and added
an interface that returns connection error state.

TBD:
I will segregate errors states in a separate header file and try to
provide more precise error states, in future. Also I will give patch
for libX11, in that patch xcb_connection_t::has_error will be passed
to default io handler of libX11. This value can then be used for
displaying error messages.

Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Arvind Umrao <arvind.umrao@oracle.com>
2012-01-11 18:01:29 +01:00
Keith Packard 9b4d6f30a3 Make xcb_take_socket keep flushing until idle
_xcb_out_flush_to will drop the iolock in pthread_cond_wait allowing
other threads to queue new requests. When this happened,
there would be requests queued for the socket after _xcb_out_flush_to
returned, and xcb_take_socket would throw an assert.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=29875
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 17:49:02 +01:00
Uli Schlachter 5ceeaaa429 Fix a dead-lock due to xcb_poll_for_reply
Imagine two threads:

Thread#1: for(;;) { xcb_get_input_focus_reply(c, xcb_get_input_focus(c), 0); }

Thread#2: for(;;) { xcb_poll_for_event(c); }

Since xcb_poll_for_event() calls _xcb_in_read() directly without synchronizing
with any other readers, this causes two threads to end up calling recv() at the
same time. We now have a race because any of these two threads could get read
the GetInputFocus reply.

If thread#2 reads this reply, it will be put in the appropriate queue and
thread#1 will still be stuck in recv(), although its reply was already received.
If no other reply or event causes this thread to wake up, the process deadlocks.

To fix this, we have to make sure that there is only ever one thread reading
from the connection. The obvious solution is to check in poll_for_next_event()
if another thread is already reading (in which case c->in.reading != 0) and not
to read from the wire in this case.

This solution is actually correct if we assume that the other thread is blocked
in poll() which means there isn't any data which can be read. Since we already
checked that there is no event in the queue this means that
poll_for_next_event() didn't find any event to return.

There might be a small race here where the other thread already determined that
there is data to read, but it still has to wait for c->iolock. However, this
means that the next poll_for_next_event() will be able to read the event, so
this shouldn't cause any problems.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-09-02 13:01:34 -04:00
Jamey Sharp b12038e9ae Keep ALIGNOF definition out of the public namespace.
Uli's patch is an excellent solution; I just want to keep the new
ALIGNOF macro hidden from XCB's users, as they don't need it to call
XCB.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-08-24 08:52:02 -07:00
Markus Duft 163c47bdc0 Support pre-IPv6 systems (without getaddrinfo)
Some of these systems (eg. Interix on XP) are still in use.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-08-24 10:49:06 -04:00
Uli Schlachter aa02096b8e Compute alignment correctly
The code previously assumed that everything has to be aligned to a 4 byte
boundary. This assumption is wrong as e.g. the STR struct from xproto shows.

Instead, each type has to be aligned to its natural alignment. So a char doesn't
need any alignment, a INT16 gets aligned to a 2-byte-boundary and a INT32 gets
the old 4 byte alignment.

I'm not 100% sure that this commit is correct, but some quick tests with awesome
and cairo-xcb went well.

This commit causes lots of dead assignments to xcb_align_to since only the last
field's alignment is actually used, but this simplified this patch a lot.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-08-24 10:28:49 -04:00