summaryrefslogtreecommitdiff
path: root/src/xcb_util.c
AgeCommit message (Collapse)Author
2017-04-01Check strdup for NULL return value.Tobias Stoeckmann
_xcb_open does not check strdup's return value for NULL if launchd suport was configured. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-01Increase unix socket send buffer to at least 64KBMark Kettenis
Some systems (e.g. OpenBSD) have a rather small default socket send buffer size of 4KB. The result is that sending requests with a largish payload requires serveral writev(2) system calls. Make sure the socket send buffer is at least 64KB such that we're likely to succeed with a single system call for most requests. A similar change was made to the xtrans code some time ago. Signed-off-by: Mark Kettenis <kettenis@openbsd.org> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2014-04-10xcb_open: Improve abstraction for launchd secure socketsJeremy Huddleston Sequoia
This changes away from hard-coding the /tmp/launch-* path to now supporting a generic <path to unix socket>[.<screen>] format for $DISPLAY. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2014-04-10xcb_open: Minor code cleanup for better readabilityJeremy Huddleston Sequoia
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Uli Schlachter <psychon@znc.in>
2014-03-21Remove tabs and trailing whitespacesUli Schlachter
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-10-11Use /usr/spool/sockets/X11/ on HP-UX for UNIX sockets (#69118).Daphne Pfister
2012-08-29Return connection failure if display string specifies non-existent screenAlan Coopersmith
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-25Always include "config.h" at the start of all C source files.Alan Coopersmith
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-04-21xcb_connect: launchd: Don't fall back on tcp if $DISPLAY is a path to a ↵Jeremy Huddleston
launchd socket Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-02-19Fallback to TCP if no protocol is specified and the UNIX connection failsJulien Cristau
Signed-off-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Jamey Sharp <jamey@minilop.net>
2012-02-09Update use of error_connection under WIN32 to _xcb_conn_ret_error()Jon TURNEY
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-01-11Use WSAStartup()/WSACleanup() on WIN32Ryan Pavlik
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-11Fix WIN32 compilation after commit 163c47bdc0d32785d831e4c93fea9ab7e023446bJon TURNEY
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-11Added more error states and removed global error_connectionArvind Umrao
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>
2011-08-24Support pre-IPv6 systems (without getaddrinfo)Markus Duft
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-18Drop AI_ADDRCONFIG when resolving TCP addressesMichael Stapelberg
When a system is completely offline (no interface has an IP address but 'lo'), xcb could not connect to localhost via TCP, e.g. connections with DISPLAY=127.0.0.1:0 fail. AI_ADDRCONFIG will only return IPv4 addresses if the system has an IPv4 address configured (likewise for IPv6). This also takes place when resolving localhost (or 127.0.0.0/8 or ::1). Also, as per RFC 3493, loopback addresses are not considered as valid addresses when determining whether to return IPv4 or IPv6 addresses. As per mailing-list discussion on the xcb list started with message 20110813215405.5818a0c1@x200, the AI_ADDRCONFIG flag is there for historical reasons: In the old days, the "default on-link" assumption in IPv6 made the flag vey much indispensable for dual-stack hosts on IPv4-only networks. Without it, there would be long timeouts trying non-existent IPv6 connectivity. Nowadays, this assumption has been flagged as historic bad practice by IETF, and hosts should have been updated to not make it anymore. Then AI_ADDRCONFIG became mostly cosmetic: it avoids phony "Protocol family not supported" or "Host unreachable" errors while trying to connect to a dual- stack mode from a host with no support for source address selection. Nowadays, on up-to-date systems, this flag is completely useless. Then again, I understood only the very latest MacOS release is "up-to-date" with this definition.
2011-04-12If protocol is "unix", use a Unix domain socket, not TCPAlan Coopersmith
Fixes fallback to local connections from Xlib's XOpenDisplay(), which will try with protocol "unix" if a hostname is specified and tcp fails (as it usually will now that most OS'es ship with -nolisten tcp enabled). Also fixes explicitly specifying DISPLAY as "unix/foo:0", which Xlib previously accepted for Unix domain sockets. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-04-12Make launchd code in xcb_util.c match surrounding code indent levelsAlan Coopersmith
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-04-04Remove unused DECnet codeAlan Coopersmith
"unifdef -UDNETCONN src/xcb_util.c" plus re-indenting code that was formerly in the else clause after a DECnet check. DECnet support has been removed from most of the X.Org code base for several years, and it appears DNETCONN was never defined in XCB. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-04Use special path to sockets when running under Solaris Trusted ExtensionsAlan Coopersmith
Solaris Trusted Extensions puts the endpoints for the X server's Unix domain sockets in a special directory shared from the global zone to each of the labeled zones, since each labeled zone has a separate /tmp. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Harris <pharris@opentext.com>
2010-12-23Merge branch 'master' of git://anongit.freedesktop.org/~peterh/libxcbPeter Harris
2010-09-19Allow disconnecting connections that are in error state.Josh Triplett
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-08Merge branch 'gsoc2010' of git://anongit.freedesktop.org/~chr/libxcbPeter Harris
2010-08-31Merge branch 'master' of git://github.com/topcat/xcb-win32Peter Harris
Conflicts: src/xcb_conn.c src/xcb_util.c Signed-off-by: Peter Harris <pharris@opentext.com>
2010-07-13added xcb_sumof() with restriction to uint8_tChristoph Reimann
2010-06-15xcb_connect_to_display_with_auth_info: Fix memory leakPauli Nieminen
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_xcb_parse_display: Fix error pathPauli Nieminen
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-05-14xcb_open: Improve protocol/host parsingJeremy Huddleston
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-04-30Fix GCC error on undeclared variable when not using abstract socketArnaud Fontaine
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-30Get rid of PATH_MAX and MAXPATHLENArnaud Fontaine
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-23Use limits.h instead of syslimits.hJeremy Huddleston
Regression found by tinderbox in 89b3485dadef47a30264a5bf150b96522183376b 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-23Reworked launchd support to work better with _xcb_parse_displayJeremy Huddleston
Fixes: http://xquartz.macosforge.org/trac/ticket/390 Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-22Set errno=0 in read_block. On Win32 there is no errno and this makes theJeetu Golani
do..while loop execute only once. Also set the return value to -1 in _xcb_open if control reaches the end - if all goes well it shouldn't reach there.
2010-03-31restablished inclusion of fcntl.h and netinet/tcp.h in xcb_util.c -- without ↵Jeetu Golani
these the code no longer compiled on *ix
2010-03-29windefs.h is now called xcb_windefs.h - changed all includes to reflect ↵Jeetu Golani
that.Replaced one instance ofWIN32 with _WIN32 in each xcb_in.c and xcb_conn.c
2010-03-26Win32 code for xcb-1.5Jeetu Golani
2010-02-17Open the X11 socket with close-on-exec flagRémi Denis-Courmont
This saves the X11 connection from leaking into children processes. On Linux, this is fully thread-safe using SOCK_CLOEXEC. On other systems, there is a small race condition. Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-02setsockopt(SO_KEEPALIVE) on TCP display connections.Adam Jackson
This matches xtrans behaviour in SocketINETConnect, and makes it so apps don't hang forever if their display dies. Signed-off-by: Adam Jackson <ajax@redhat.com>
2009-05-26Disable Nagle on TCP socketelupus
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10util: remove useless strlen calls from decnet openingJulien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10util: merge common code for xcb_connectJulien Danjou
Many code was duplicated between xcb_connect_to_display_with_auth_info and xcb_connect(). We merge both, since the difference is just about the xcb_auth_info_t pointer being supplied, or not. Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10util: open_abstract gets filelen as parametersJulien Danjou
That saves us from a couple of strlen() calls. Signed-off-by: Julien Danjou <julien@danjou.info>
2008-11-23Shutup compiler warning about unused variable...Jeremy Huddleston
2008-11-23Apple: Apple launchd cleanupJeremy Huddleston
Added --with-launchd option instead of just using __APPLE__ Fixed opening launchd fd when displayname=NULL
2008-11-23Apple: Enable support for launchd DISPLAY socketJeremy Huddleston
2008-09-09Add support for the abstract socket namespace under LinuxJulien Cristau
Based on same in Xtrans. Signed-off-by: Julien Danjou <julien@danjou.info>
2008-09-09Fix some fd leaks in _xcb_open_*()Julien Cristau
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28Initialize all fields of addrinfoJulien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28Use ifdef instead of if for defined valueJulien Danjou
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-07-07fix FreeBSD supportPetr Salinger
The GNU/kFreeBSD (and BSDs in general) have a different layout of struct sockaddr, sockaddr_in, sockaddr_un ... The first member do not have to be "sa_family", they also have "sa_len" field. Signed-off-by: Julien Danjou <julien@danjou.info>