Do not clear last error if not reconnecting.
authorArmin Novak <armin.novak@thincast.com>
Wed, 11 Apr 2018 07:30:40 +0000 (09:30 +0200)
committerArmin Novak <armin.novak@thincast.com>
Wed, 11 Apr 2018 08:06:11 +0000 (10:06 +0200)
libfreerdp/core/connection.c
libfreerdp/core/connection.h
libfreerdp/core/freerdp.c

index c3f953e..3b3b689 100644 (file)
@@ -331,7 +331,19 @@ BOOL rdp_client_disconnect(rdpRdp* rdp)
        if (freerdp_channels_disconnect(context->channels, context->instance) != CHANNEL_RC_OK)
                return FALSE;
 
-       freerdp_set_last_error(context, FREERDP_ERROR_SUCCESS);
+       return TRUE;
+}
+
+BOOL rdp_client_disconnect_and_clear(rdpRdp* rdp)
+{
+       rdpContext* context;
+
+       if (!rdp_client_disconnect(rdp))
+               return FALSE;
+
+       context = rdp->context;
+
+       context->LastError = FREERDP_ERROR_SUCCESS;
        clearChannelError(context);
        ResetEvent(context->abortEvent);
        return TRUE;
@@ -343,7 +355,7 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
        rdpSettings* settings;
        rdpContext* context;
 
-       if (!rdp_client_disconnect(rdp))
+       if (!rdp_client_disconnect_and_clear(rdp))
                return FALSE;
 
        settings = rdp->settings;
@@ -417,7 +429,7 @@ BOOL rdp_client_reconnect(rdpRdp* rdp)
        rdpContext* context = rdp->context;
        rdpChannels* channels = context->channels;
 
-       if (!rdp_client_disconnect(rdp))
+       if (!rdp_client_disconnect_and_clear(rdp))
                return FALSE;
 
        status = rdp_client_connect(rdp);
index 7a6ebf5..62aaea0 100644 (file)
@@ -51,6 +51,7 @@ enum CONNECTION_STATE
 
 FREERDP_LOCAL BOOL rdp_client_connect(rdpRdp* rdp);
 FREERDP_LOCAL BOOL rdp_client_disconnect(rdpRdp* rdp);
+FREERDP_LOCAL BOOL rdp_client_disconnect_and_clear(rdpRdp* rdp);
 FREERDP_LOCAL BOOL rdp_client_reconnect(rdpRdp* rdp);
 FREERDP_LOCAL BOOL rdp_client_redirect(rdpRdp* rdp);
 FREERDP_LOCAL BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp,
index ed0e6ce..676a6b8 100644 (file)
@@ -158,7 +158,7 @@ BOOL freerdp_connect(freerdp* instance)
 
        /* We always set the return code to 0 before we start the connect sequence*/
        connectErrorCode = 0;
-       freerdp_set_last_error(instance->context, FREERDP_ERROR_SUCCESS);
+       instance->context->LastError = FREERDP_ERROR_SUCCESS;
        clearChannelError(instance->context);
        ResetEvent(instance->context->abortEvent);
        rdp = instance->context->rdp;
@@ -517,7 +517,7 @@ BOOL freerdp_disconnect(freerdp* instance)
 BOOL freerdp_disconnect_before_reconnect(freerdp* instance)
 {
        rdpRdp* rdp = instance->context->rdp;
-       return rdp_client_disconnect(rdp);
+       return rdp_client_disconnect_and_clear(rdp);
 }
 
 BOOL freerdp_reconnect(freerdp* instance)