Hello, Am Dienstag 29 Januar 2013 17:51:43 schrieb Philipp Hahn: > Am Freitag 25 Januar 2013 11:46:03 schrieb Kevin Cave: > > Bingo! Starting xrdp as root did the trick. There was one "connect error" > > initially, but connected on the second attempt, and after that I can > > reconnect to the same session perfectly. > > Then you're lucky, because when X11rdp needs some time to start (because > for example the server is loaded), the initial connection will fail. xrdp > only tries 4*250ms to open the UNIX socket of xrdp. > See <https://forge.univention.org/bugzilla/attachment.cgi?id=5015> for a > quick patch if you encounter that.
Attached is a patch which handles the UNIX socket problem hopefully better: The problem with UNIX socket is that you get an instant error, and then the 250ms delay is not enouth for the X11rdp server to start. The patch increments the timeout to 1s for that case and handles the error codes returned by connect() more cleverly, for example doesn't yell "error" to loudly when the socket is not yet there. The patch is probably not ready to be applied upstream, since the low-level socket handling code lives mostly in common/os_calls.[ch]. Sincerely Philipp PS: Can I / someone please rename "g_tcp_local_*socket" to "g_unix_*socket", because a UNIX socket is not an IP socket and talking about TCP there is ... horrible. -- Philipp Hahn Open Source Software Engineer h...@univention.de Univention GmbH be open. fon: +49 421 22 232- 0 Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99 http://www.univention.de/
From 69234732e0eea0e3b31166ff60248075447df796 Mon Sep 17 00:00:00 2001 Message-Id: <69234732e0eea0e3b31166ff60248075447df796.1359538916.git.h...@univention.de> In-Reply-To: <16a811cc5e16eb50734f92cd8adc7182031515e8.1359538916.git.h...@univention.de> References: <16a811cc5e16eb50734f92cd8adc7182031515e8.1359538916.git.h...@univention.de> From: Philipp Hahn <h...@univention.de> Date: Tue, 29 Jan 2013 07:40:40 +0100 Subject: [PATCH 3/3] xup: handle UNIX socket timeout Organization: Univention GmbH, Bremen, Germany X11rdp some times need more then 1 second to start, in which case xrdp fails to open a connection to the UNIX socket. Rework error handling to have one exit point. Handle UNIX socket connect errors in more detail. Increase the timeout. --- xup/xup.c | 63 ++++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 38 insertions(+), 25 deletions(-) diff --git a/xup/xup.c b/xup/xup.c index 15498e6..8d4061f 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -19,6 +19,7 @@ */ #include "xup.h" +#include <errno.h> /******************************************************************************/ /* returns error */ @@ -153,15 +154,13 @@ lib_mod_connect(struct mod *mod) { mod->server_msg(mod, "error - only supporting 8, 15, 16, and 24 bpp rdp connections", 0); - LIB_DEBUG(mod, "out lib_mod_connect error"); - return 1; + goto error0; } if (g_strcmp(mod->ip, "") == 0) { mod->server_msg(mod, "error - no ip set", 0); - LIB_DEBUG(mod, "out lib_mod_connect error"); - return 1; + goto error0; } make_stream(s); @@ -174,10 +173,14 @@ lib_mod_connect(struct mod *mod) } mod->sck_closed = 0; - i = 0; - while (1) + for (i = 0; i < 5; i++) { + if (i > 0) + { + g_sleep(use_uds ? 1000 : 250); + } + if (use_uds) { mod->sck = g_tcp_local_socket(); @@ -194,6 +197,18 @@ lib_mod_connect(struct mod *mod) if (use_uds) { error = g_tcp_local_connect(mod->sck, con_port); + if (error == -1) + { + switch (errno) { + case EACCES: /* no write permission */ + case EPERM: /* not permitted */ + mod->server_msg(mod, "connection denied", 0); + goto error1; /* permanent error */ + case ENOENT: /* socket does not (yet) exist */ + case ECONNREFUSED: /* not a socket or no one listening (yet) */ + goto again; /* temporary error */ + } + } } else { @@ -204,20 +219,16 @@ lib_mod_connect(struct mod *mod) { if (g_tcp_last_error_would_block(mod->sck)) { - error = 0; - index = 0; - - while (!g_tcp_can_send(mod->sck, 100)) + for (index = 0; !g_tcp_can_send(mod->sck, 100); index++) { - index++; - if ((index >= 30) || mod->server_is_term(mod)) { mod->server_msg(mod, "connect timeout", 0); - error = 1; - break; + goto again; } } + + error = 0; } else { @@ -230,17 +241,14 @@ lib_mod_connect(struct mod *mod) break; } +again: g_tcp_close(mod->sck); mod->sck = 0; - i++; - - if (i >= 4) - { - mod->server_msg(mod, "connection problem, giving up", 0); - break; - } - - g_sleep(250); + } + if (!mod->sck) + { + mod->server_msg(mod, "connection problem, giving up", 0); + goto error1; } if (error == 0) @@ -306,8 +314,7 @@ lib_mod_connect(struct mod *mod) if (error != 0) { mod->server_msg(mod, "some problem", 0); - LIB_DEBUG(mod, "out lib_mod_connect error"); - return 1; + goto error0; } else { @@ -317,6 +324,12 @@ lib_mod_connect(struct mod *mod) LIB_DEBUG(mod, "out lib_mod_connect"); return 0; + +error1: + free_stream(s); +error0: + LIB_DEBUG(mod, "out lib_mod_connect error"); + return 1; } /******************************************************************************/ -- 1.7.1
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________ xrdp-devel mailing list xrdp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xrdp-devel