summaryrefslogtreecommitdiffstats
path: root/xup
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2009-08-17 19:36:08 +0000
committerjsorg71 <jsorg71>2009-08-17 19:36:08 +0000
commitb10851d32749d2ddfc605d898ee123c043d3bde3 (patch)
treee7f1b282f43a0512e68abccd836bea3477f97c68 /xup
parentd9516e6837261dedaf3da1d707fde6e81127714f (diff)
downloadxrdp-proprietary-b10851d32749d2ddfc605d898ee123c043d3bde3.tar.gz
xrdp-proprietary-b10851d32749d2ddfc605d898ee123c043d3bde3.zip
try to connect more than once
Diffstat (limited to 'xup')
-rw-r--r--xup/xup.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/xup/xup.c b/xup/xup.c
index 20174365..437b900a 100644
--- a/xup/xup.c
+++ b/xup/xup.c
@@ -129,6 +129,7 @@ lib_mod_connect(struct mod* mod)
int error;
int len;
int i;
+ int index;
struct stream* s;
char con_port[256];
@@ -157,12 +158,47 @@ lib_mod_connect(struct mod* mod)
g_sprintf(con_port, "%s", mod->port);
mod->sck = g_tcp_socket();
mod->sck_obj = g_create_wait_obj_from_socket(mod->sck, 0);
+ g_tcp_set_non_blocking(mod->sck);
+ g_tcp_set_no_delay(mod->sck);
mod->sck_closed = 0;
- error = g_tcp_connect(mod->sck, mod->ip, con_port);
- if (error == 0)
+ i = 0;
+ while (1)
{
- g_tcp_set_non_blocking(mod->sck);
- g_tcp_set_no_delay(mod->sck);
+ mod->server_msg(mod, "connecting...", 0);
+ error = g_tcp_connect(mod->sck, mod->ip, con_port);
+ if (error == -1)
+ {
+ if (g_tcp_last_error_would_block(mod->sck))
+ {
+ error = 0;
+ index = 0;
+ while (!g_tcp_can_send(mod->sck, 100))
+ {
+ index++;
+ if ((index >= 30) || mod->server_is_term(mod))
+ {
+ mod->server_msg(mod, "connect timeout", 0);
+ error = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ mod->server_msg(mod, "connect error", 0);
+ }
+ }
+ if (error == 0)
+ {
+ break;
+ }
+ i++;
+ if (i >= 4)
+ {
+ mod->server_msg(mod, "connect problem, giving up", 0);
+ break;
+ }
+ g_sleep(250);
}
if (error == 0)
{
@@ -191,6 +227,10 @@ lib_mod_connect(struct mod* mod)
LIB_DEBUG(mod, "out lib_mod_connect error");
return 1;
}
+ else
+ {
+ mod->server_msg(mod, "connected ok", 0);
+ }
LIB_DEBUG(mod, "out lib_mod_connect");
return 0;
}