mp_session: Always use global displayname
authorFrederic Koehler <f.koehler427@gmail.com>
Wed, 15 Aug 2012 01:49:14 +0000 (21:49 -0400)
committerJon Trulson <jon@radscan.com>
Wed, 15 Aug 2012 02:37:59 +0000 (20:37 -0600)
This code tried to automatically generate the X DISPLAY
from the combination of the hostname and display number;
however 127.0.0.1:0 is normally rejected by X11, so this
technique is no good. Fixes dticon hang on startup, caused by
XOpenDisplay failure leading to this message from tttrace:
tt_default_session_set(0x0x875190=="X 127.0.0.1 0") = 1032 (TT_ERR_ACCESS)

cde/lib/tt/lib/mp/mp_session.C

index ed96227500857a6a4271b8d03bafaf7df85e2c4b..73bbe185a82eaf6496a0c3f7ed7b26c16b3c3be2 100644 (file)
@@ -793,8 +793,17 @@ set_id(char *id)
                        if (sscanf((char *)id, "X %s %d", host, &svnum) != 2) {
                                return(TT_ERR_SESSION);
                        }
+                       /* We _cannot_ set _displayname based solely on host and svnum, 
+                        * because :0 is NOT the same as 127.0.0.1:0 as far as X11
+                        * is concerned: by default, it will only accept connections
+                        * to the former. (XOpenDisplay etc. will fail if you try the below!)
                        sprintf(dpname, "%s:%d", host, svnum);
                        _displayname = dpname;
+                        */
+                       if (! _displayname.len()) {
+                               _displayname = _tt_global->xdisplayname;
+                       }
+
                        _server_num = svnum;
                        _env = _TT_ENV_X11;
                        break;