[Xcb] [PATCH 1/2 libX11] xcb: Add TCP fallback
Julien Cristau
jcristau at debian.org
Fri May 14 13:42:42 PDT 2010
On Fri, May 14, 2010 at 13:10:36 -0700, Jeremy Huddleston wrote:
> @@ -164,10 +164,32 @@ XOpenDisplay (
>
> #if USE_XCB
> if(!_XConnectXCB(dpy, display, &fullname, &iscreen)) {
> + /* Try falling back on other transports if no transport specified */
> + const char *slash = strrchr(display_name, '/');
> + if(slash == NULL) {
> + const char *protocols[] = {"local", "unix", "tcp", "inet6", "inet", NULL};
> + const char **s;
> + size_t buf_size = strlen(display_name) + 7; // max strlen + 2 (null + /)
> + char *buf = (char *)Xcalloc(buf_size, sizeof(char));
> +
The cast is not necessary, and I think Xmalloc(buf_size) would be enough
since we'll initialize that buffer with snprintf below anyway.
> + if(!buf) {
> + dpy->display_name = fullname;
> + OutOfMemory(dpy, NULL);
> + return NULL;
> + }
> +
> + for(s = protocols; *s; s++) {
> + snprintf(buf, buf_size, "%s/%s", *s, display_name);
> + if(_XConnectXCB(dpy, buf, &fullname, &iscreen))
> + goto fallback_success;
> + }
> + }
> +
> dpy->display_name = fullname;
> OutOfMemory(dpy, NULL);
> return NULL;
> }
> +fallback_success:
> #else /* !USE_XCB */
> if ((dpy->trans_conn = _X11TransConnectDisplay (
> display_name, &fullname, &idisplay,
Cheers,
Julien
More information about the xorg-devel
mailing list