Re-wrote top main loop. The patch for session directory / load

balancing redirection made it *way* too complicated. We shouldn't
really need two extra state variables in addition to g_redirect. The
current approach also does not support future features such as
automatic reconnection in case of network problems. 

The new loop should be functionally equivalent to the previous one,
though it hasn't yet been tested with a load balancing server.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1547 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2010-01-13 16:07:29 +00:00
parent 9a926834ff
commit 5b75525080

View File

@ -455,8 +455,6 @@ main(int argc, char *argv[])
char *locale = NULL;
int username_option = 0;
RD_BOOL geometry_option = False;
int run_count = 0; /* Session Directory support */
RD_BOOL continue_connect = True; /* Session Directory support */
#ifdef WITH_RDPSND
char *rdpsnd_optarg = NULL;
#endif
@ -963,16 +961,23 @@ main(int argc, char *argv[])
rdpdr_init();
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */
while (1)
{
ui_init_connection();
rdesktop_reset_state();
if (run_count == 0)
if (g_redirect)
{
if (!rdp_connect(server, flags, domain, password, shell, directory, False))
return EX_PROTOCOL;
STRNCPY(domain, g_redirect_domain, sizeof(domain));
xfree(g_username);
g_username = (char *) xmalloc(strlen(g_redirect_username) + 1);
STRNCPY(g_username, g_redirect_username, sizeof(g_username));
STRNCPY(password, g_redirect_password, sizeof(password));
STRNCPY(server, g_redirect_server, sizeof(server));
flags |= RDP_LOGON_AUTO;
}
else if (!rdp_connect(server, flags, domain, password, shell, directory, True))
ui_init_connection();
if (!rdp_connect(server, flags, domain, password, shell, directory, g_redirect))
return EX_PROTOCOL;
/* By setting encryption to False here, we have an encrypted login
@ -984,39 +989,20 @@ main(int argc, char *argv[])
DEBUG(("Connection successful.\n"));
memset(password, 0, sizeof(password));
if (run_count == 0)
if (!g_redirect)
if (!ui_create_window())
return EX_OSERR;
if (continue_connect)
rdp_main_loop(&deactivated, &ext_disc_reason);
g_redirect = False;
rdp_main_loop(&deactivated, &ext_disc_reason);
DEBUG(("Disconnecting...\n"));
rdp_disconnect();
if ((g_redirect == True) && (run_count == 0)) /* Support for Session Directory */
{
/* reset state of major globals */
rdesktop_reset_state();
STRNCPY(domain, g_redirect_domain, sizeof(domain));
xfree(g_username);
g_username = (char *) xmalloc(strlen(g_redirect_username) + 1);
STRNCPY(g_username, g_redirect_username, sizeof(g_username));
STRNCPY(password, g_redirect_password, sizeof(password));
STRNCPY(server, g_redirect_server, sizeof(server));
flags |= RDP_LOGON_AUTO;
g_redirect = False;
}
else
{
continue_connect = False;
ui_destroy_window();
break;
}
run_count++;
if (g_redirect)
continue;
ui_destroy_window();
break;
}
cache_save_state();