diff options
author | Peter Jeremy <peterjeremy@acm.org> | 2012-02-28 08:38:46 +1100 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-08 11:16:13 -0700 |
commit | ea0a2788b1e82f2b19a3c46e6d42d0a86fd17f38 (patch) | |
tree | 0a82998751758c19779f34940f6b0605a73af6e9 /fd.c | |
parent | c328376384a64f6dbdc476a1d6c5244aad8261ec (diff) | |
download | xscope-ea0a2788b1e82f2b19a3c46e6d42d0a86fd17f38.tar.gz |
Bug 46696 - Try alternate protocol on X11 connection failure.
In USE_XTRANS mode, MakeConnection() cycles through a selection of
protocol choices until it finds one where it can open a socket to
the server. It then attempts an X11 connection via that socket and
aborts if one isn't possible.
This patch modifies the code to try an alternate protocol if the X11
connection fails.
https://bugs.freedesktop.org/show_bug.cgi?id=46696
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'fd.c')
-rw-r--r-- | fd.c | 36 |
1 files changed, 23 insertions, 13 deletions
@@ -270,20 +270,30 @@ MakeConnection( int connect_stat; const char *protocols[] = {"local", "unix", "tcp", "inet6", "inet", NULL}; const char **s; - - for(*trans_conn = NULL, s = protocols; *trans_conn == NULL && *s; s++) { - snprintf (address, sizeof(address), "%s/%s:%ld", *s, server, port - ServerBasePort); - *trans_conn = _X11TransOpenCOTSClient(address); - } - if(*trans_conn == NULL) { - debug(1,(stderr, "OpenCOTSClient failed\n")); - panic("Can't open connection to Server"); + + enterprocedure("ConnectToServer"); + s = protocols; + while (*s) { + *trans_conn = NULL; + snprintf (address, sizeof(address), "%s/%s:%ld", *s++, server, port - ServerBasePort); + debug(4,(stderr, "Trying %s ", address)); + *trans_conn = _X11TransOpenCOTSClient(address); + if(*trans_conn == NULL) { + debug(1,(stderr, "OpenCOTSClient %s failed\n", address)); + continue; + } + debug(4,(stderr, "Opened ")); + if ((connect_stat = _X11TransConnect(*trans_conn,address)) < 0 ) { + _X11TransClose(*trans_conn); + *trans_conn = NULL; + debug(1,(stderr, "TransConnect %s failed\n", address)); + continue; + } + debug(4,(stderr, "Connected\n")); + break; } - if ((connect_stat = _X11TransConnect(*trans_conn,address)) < 0 ) { - _X11TransClose(*trans_conn); - *trans_conn = NULL; - debug(1,(stderr, "TransConnect failed\n")); - panic("Can't open connection to Server"); + if (*trans_conn == NULL) { + panic("Can't open connection to Server"); } ServerFD = _X11TransGetConnectionNumber(*trans_conn); |