summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Mikaelsson <derfian@cendio.se>2018-03-12 14:09:07 +0100
committerKarl Mikaelsson <derfian@cendio.se>2018-03-22 15:31:37 +0100
commit8c9c52abd2fc45597d5c4ac59d692930fc5e51da (patch)
treed23a76cb09cdf93c270f52ce46491cda8877d5de
parent4580492c1224f9c5d72f8863e8027563d58494ec (diff)
downloadrdesktop-8c9c52abd2fc45597d5c4ac59d692930fc5e51da.zip
Don't check server error codes if the server didn't disconnect us
When a user presses cancel in the login dialog on a session on Windows 2008 R2 while a resize was pending, the user would be reconnected to the session rather than disconnected. A naive fix for this problem led to problems where reconnecting to resize a session led to the user being disconnected instead. The solution for both of these problems is to only look at the error code sent by the server is if the connection also was deactivated at the time of the disconnect. In just about all other cases, a disconnect/main loop quit when the connection is active should result in a reconnect. The sole exception is if the user closed the rdesktop window, in case rdesktop also should exit.
-rw-r--r--rdesktop.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/rdesktop.c b/rdesktop.c
index 522eaff..cb5e4b1 100644
--- a/rdesktop.c
+++ b/rdesktop.c
@@ -1395,55 +1395,56 @@ main(int argc, char *argv[])
deactivated = False;
g_reconnect_loop = False;
- ext_disc_reason = 0;
rdp_main_loop(&deactivated, &ext_disc_reason);
tcp_run_ui(False);
-
- logger(Core, Verbose, "Disconnecting...");
rdp_disconnect();
- /* If error info is set we do want to exit rdesktop
- connect loop. We do this by clearing flags that
- triggers a reconnect that could be set elsewere */
- if (ext_disc_reason != 0)
+ if (deactivated)
{
- g_redirect = False;
- g_network_error = False;
- g_pending_resize = False;
+ /* Server disconnected while deactivated */
+ logger(Core, Notice, "Disconnecting...");
+ break;
}
-
- if (g_redirect)
- continue;
-
- /* handle network error and start autoreconnect */
- if (g_network_error && !deactivated)
+ else
{
- logger(Core, Notice,
- "Disconnected due to network error, retrying to reconnect for %d minutes.",
- RECONNECT_TIMEOUT / 60);
- g_network_error = False;
- g_reconnect_loop = True;
- continue;
- }
-
- ui_seamless_end();
- ui_destroy_window();
+ /* Unexpected disconnect or rdesktop-initiated loop exit */
- /* Enter a reconnect loop if we have a pending resize request */
- if (g_pending_resize)
- {
- logger(Core, Verbose, "Resize reconnect loop triggered, new size %dx%d",
- g_requested_session_width, g_requested_session_height);
- g_pending_resize = False;
- g_reconnect_loop = True;
+ if (g_user_quit)
+ {
+ /* User closed window */
+ break;
+ }
+ else if (g_redirect)
+ {
+ /* see beginning of loop */
+ }
+ else if (g_network_error)
+ {
+ logger(Core, Notice,
+ "Disconnected due to network error, retrying to reconnect for %d minutes.",
+ RECONNECT_TIMEOUT / 60);
+ g_network_error = False;
+ g_reconnect_loop = True;
+ }
+ else if (g_pending_resize)
+ {
+ /* Prepare to re-create rdesktop window */
+ ui_seamless_end();
+ ui_destroy_window();
+
+ logger(Core, Verbose, "Resize reconnect loop triggered, new size %dx%d",
+ g_requested_session_width, g_requested_session_height);
+ g_pending_resize = False;
+ g_reconnect_loop = True;
+ }
continue;
}
-
- /* exit main reconnect loop */
- break;
}
+ ui_seamless_end();
+ ui_destroy_window();
+
cache_save_state();
ui_deinit();