Merge pull request #2301 from akallabeth/disconnect_fix
Disconnect / Reconnect fix
This commit is contained in:
commit
620694c10a
@ -716,7 +716,7 @@ BOOL xf_get_pixmap_info(xfContext* xfc)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
vi = NULL;
|
vi = vis;
|
||||||
|
|
||||||
for (i = 0; i < vi_count; i++)
|
for (i = 0; i < vi_count; i++)
|
||||||
{
|
{
|
||||||
@ -802,6 +802,7 @@ static void xf_post_disconnect(freerdp* instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xf_monitors_free(xfc, instance->settings);
|
xf_monitors_free(xfc, instance->settings);
|
||||||
|
gdi_free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xf_play_sound(rdpContext* context, PLAY_SOUND_UPDATE* play_sound)
|
static void xf_play_sound(rdpContext* context, PLAY_SOUND_UPDATE* play_sound)
|
||||||
@ -1657,7 +1658,6 @@ void* xf_thread(void *param)
|
|||||||
exit_code = freerdp_error_info(instance);
|
exit_code = freerdp_error_info(instance);
|
||||||
|
|
||||||
freerdp_disconnect(instance);
|
freerdp_disconnect(instance);
|
||||||
gdi_free(instance);
|
|
||||||
|
|
||||||
ExitThread(exit_code);
|
ExitThread(exit_code);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1763,6 +1763,7 @@ static int xfreerdp_client_start(rdpContext* context)
|
|||||||
WLog_ERR(TAG, "error: server hostname was not specified with /v:<server>[:port]");
|
WLog_ERR(TAG, "error: server hostname was not specified with /v:<server>[:port]");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
xfc->disconnect = FALSE;
|
||||||
xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread,
|
xfc->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread,
|
||||||
context->instance, 0, NULL);
|
context->instance, 0, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -319,7 +319,18 @@ BOOL rdp_client_connect(rdpRdp* rdp)
|
|||||||
|
|
||||||
BOOL rdp_client_disconnect(rdpRdp* rdp)
|
BOOL rdp_client_disconnect(rdpRdp* rdp)
|
||||||
{
|
{
|
||||||
return transport_disconnect(rdp->transport);
|
BOOL rc;
|
||||||
|
|
||||||
|
if (rdp->settingsCopy)
|
||||||
|
{
|
||||||
|
freerdp_settings_free(rdp->settingsCopy);
|
||||||
|
rdp->settingsCopy = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = nego_disconnect(rdp->nego);
|
||||||
|
rdp_reset(rdp);
|
||||||
|
rdp_client_transition_to_state(rdp, CONNECTION_STATE_INITIAL);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL rdp_client_redirect(rdpRdp* rdp)
|
BOOL rdp_client_redirect(rdpRdp* rdp)
|
||||||
@ -328,9 +339,6 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
|
|||||||
rdpSettings* settings = rdp->settings;
|
rdpSettings* settings = rdp->settings;
|
||||||
|
|
||||||
rdp_client_disconnect(rdp);
|
rdp_client_disconnect(rdp);
|
||||||
|
|
||||||
rdp_reset(rdp);
|
|
||||||
|
|
||||||
rdp_redirection_apply_settings(rdp);
|
rdp_redirection_apply_settings(rdp);
|
||||||
|
|
||||||
if (settings->RedirectionFlags & LB_LOAD_BALANCE_INFO)
|
if (settings->RedirectionFlags & LB_LOAD_BALANCE_INFO)
|
||||||
@ -373,15 +381,6 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL rdp_client_reconnect(rdpRdp* rdp)
|
|
||||||
{
|
|
||||||
rdp_client_disconnect(rdp);
|
|
||||||
|
|
||||||
rdp_reset(rdp);
|
|
||||||
|
|
||||||
return rdp_client_connect(rdp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BYTE fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
|
static BYTE fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
|
||||||
|
|
||||||
static BOOL rdp_client_establish_keys(rdpRdp* rdp)
|
static BOOL rdp_client_establish_keys(rdpRdp* rdp)
|
||||||
@ -758,7 +757,7 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream *s)
|
BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s)
|
||||||
{
|
{
|
||||||
BYTE* mark;
|
BYTE* mark;
|
||||||
UINT16 length;
|
UINT16 length;
|
||||||
@ -1153,7 +1152,6 @@ BOOL rdp_server_reactivate(rdpRdp* rdp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rdp->AwaitCapabilities = TRUE;
|
rdp->AwaitCapabilities = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1239,7 +1237,6 @@ int rdp_server_transition_to_state(rdpRdp* rdp, int state)
|
|||||||
* PostConnect should only be called once and should not
|
* PostConnect should only be called once and should not
|
||||||
* be called after a reactivation sequence.
|
* be called after a reactivation sequence.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IFCALLRET(client->PostConnect, client->connected, client);
|
IFCALLRET(client->PostConnect, client->connected, client);
|
||||||
|
|
||||||
if (!client->connected)
|
if (!client->connected)
|
||||||
|
@ -48,8 +48,8 @@ enum CONNECTION_STATE
|
|||||||
};
|
};
|
||||||
|
|
||||||
BOOL rdp_client_connect(rdpRdp* rdp);
|
BOOL rdp_client_connect(rdpRdp* rdp);
|
||||||
|
BOOL rdp_client_disconnect(rdpRdp* rdp);
|
||||||
BOOL rdp_client_redirect(rdpRdp* rdp);
|
BOOL rdp_client_redirect(rdpRdp* rdp);
|
||||||
BOOL rdp_client_reconnect(rdpRdp* rdp);
|
|
||||||
BOOL rdp_client_connect_mcs_connect_response(rdpRdp* rdp, wStream* s);
|
BOOL rdp_client_connect_mcs_connect_response(rdpRdp* rdp, wStream* s);
|
||||||
BOOL rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, wStream* s);
|
BOOL rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, wStream* s);
|
||||||
BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s);
|
BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s);
|
||||||
|
@ -318,8 +318,7 @@ BOOL freerdp_disconnect(freerdp* instance)
|
|||||||
rdpRdp* rdp;
|
rdpRdp* rdp;
|
||||||
|
|
||||||
rdp = instance->context->rdp;
|
rdp = instance->context->rdp;
|
||||||
transport_disconnect(rdp->transport);
|
rdp_client_disconnect(rdp);
|
||||||
|
|
||||||
update_post_disconnect(instance->update);
|
update_post_disconnect(instance->update);
|
||||||
IFCALL(instance->PostDisconnect, instance);
|
IFCALL(instance->PostDisconnect, instance);
|
||||||
|
|
||||||
@ -335,7 +334,8 @@ BOOL freerdp_disconnect(freerdp* instance)
|
|||||||
|
|
||||||
BOOL freerdp_reconnect(freerdp* instance)
|
BOOL freerdp_reconnect(freerdp* instance)
|
||||||
{
|
{
|
||||||
return rdp_client_reconnect(instance->context->rdp);
|
freerdp_disconnect(instance);
|
||||||
|
return freerdp_connect(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL freerdp_shall_disconnect(freerdp* instance)
|
BOOL freerdp_shall_disconnect(freerdp* instance)
|
||||||
|
@ -63,7 +63,9 @@ static const char PROTOCOL_SECURITY_STRINGS[9][4] =
|
|||||||
};
|
};
|
||||||
#endif /* WITH_DEBUG_NEGO */
|
#endif /* WITH_DEBUG_NEGO */
|
||||||
|
|
||||||
BOOL nego_security_connect(rdpNego* nego);
|
static BOOL nego_transport_connect(rdpNego* nego);
|
||||||
|
static BOOL nego_transport_disconnect(rdpNego* nego);
|
||||||
|
static BOOL nego_security_connect(rdpNego* nego);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negotiate protocol security and connect.
|
* Negotiate protocol security and connect.
|
||||||
@ -190,6 +192,13 @@ BOOL nego_connect(rdpNego* nego)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL nego_disconnect(rdpNego* nego)
|
||||||
|
{
|
||||||
|
rdpSettings* settings = nego->transport->settings;
|
||||||
|
nego->state = NEGO_STATE_INITIAL;
|
||||||
|
return nego_transport_disconnect(nego);
|
||||||
|
}
|
||||||
|
|
||||||
/* connect to selected security layer */
|
/* connect to selected security layer */
|
||||||
BOOL nego_security_connect(rdpNego* nego)
|
BOOL nego_security_connect(rdpNego* nego)
|
||||||
{
|
{
|
||||||
@ -281,7 +290,7 @@ BOOL nego_transport_connect(rdpNego* nego)
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int nego_transport_disconnect(rdpNego* nego)
|
BOOL nego_transport_disconnect(rdpNego* nego)
|
||||||
{
|
{
|
||||||
if (nego->tcp_connected)
|
if (nego->tcp_connected)
|
||||||
transport_disconnect(nego->transport);
|
transport_disconnect(nego->transport);
|
||||||
@ -289,7 +298,7 @@ int nego_transport_disconnect(rdpNego* nego)
|
|||||||
nego->tcp_connected = FALSE;
|
nego->tcp_connected = FALSE;
|
||||||
nego->security_connected = FALSE;
|
nego->security_connected = FALSE;
|
||||||
|
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,6 +118,7 @@ struct rdp_nego
|
|||||||
typedef struct rdp_nego rdpNego;
|
typedef struct rdp_nego rdpNego;
|
||||||
|
|
||||||
BOOL nego_connect(rdpNego* nego);
|
BOOL nego_connect(rdpNego* nego);
|
||||||
|
BOOL nego_disconnect(rdpNego* nego);
|
||||||
|
|
||||||
BOOL nego_send_preconnection_pdu(rdpNego* nego);
|
BOOL nego_send_preconnection_pdu(rdpNego* nego);
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ void nego_process_negotiation_response(rdpNego* nego, wStream* s);
|
|||||||
void nego_process_negotiation_failure(rdpNego* nego, wStream* s);
|
void nego_process_negotiation_failure(rdpNego* nego, wStream* s);
|
||||||
BOOL nego_send_negotiation_response(rdpNego* nego);
|
BOOL nego_send_negotiation_response(rdpNego* nego);
|
||||||
|
|
||||||
rdpNego* nego_new(struct rdp_transport * transport);
|
rdpNego* nego_new(struct rdp_transport* transport);
|
||||||
void nego_free(rdpNego* nego);
|
void nego_free(rdpNego* nego);
|
||||||
|
|
||||||
void nego_init(rdpNego* nego);
|
void nego_init(rdpNego* nego);
|
||||||
|
@ -1439,6 +1439,10 @@ void rdp_reset(rdpRdp* rdp)
|
|||||||
rdp->nego = nego_new(rdp->transport);
|
rdp->nego = nego_new(rdp->transport);
|
||||||
rdp->mcs = mcs_new(rdp->transport);
|
rdp->mcs = mcs_new(rdp->transport);
|
||||||
rdp->transport->layer = TRANSPORT_LAYER_TCP;
|
rdp->transport->layer = TRANSPORT_LAYER_TCP;
|
||||||
|
rdp->disconnect = FALSE;
|
||||||
|
rdp->errorInfo = 0;
|
||||||
|
rdp->deactivation_reactivation = 0;
|
||||||
|
rdp->finalize_sc_pdus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,8 +102,40 @@ BOOL transport_disconnect(rdpTransport* transport)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
transport_stop(transport);
|
transport_stop(transport);
|
||||||
BIO_free_all(transport->frontBio);
|
|
||||||
transport->frontBio = 0;
|
if (transport->frontBio)
|
||||||
|
{
|
||||||
|
BIO_free_all(transport->frontBio);
|
||||||
|
transport->frontBio = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transport->TlsIn)
|
||||||
|
tls_free(transport->TlsIn);
|
||||||
|
|
||||||
|
if (transport->TlsOut != transport->TlsIn)
|
||||||
|
tls_free(transport->TlsOut);
|
||||||
|
|
||||||
|
transport->TlsIn = NULL;
|
||||||
|
transport->TlsOut = NULL;
|
||||||
|
|
||||||
|
if (transport->tsg)
|
||||||
|
{
|
||||||
|
tsg_free(transport->tsg);
|
||||||
|
transport->tsg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transport->TcpOut != transport->TcpIn)
|
||||||
|
freerdp_tcp_free(transport->TcpOut);
|
||||||
|
|
||||||
|
transport->TcpOut = NULL;
|
||||||
|
|
||||||
|
if (transport->TsgTls)
|
||||||
|
{
|
||||||
|
tls_free(transport->TsgTls);
|
||||||
|
transport->TsgTls = NULL;
|
||||||
|
}
|
||||||
|
transport->layer = TRANSPORT_LAYER_TCP;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,9 +154,7 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
rdpTsg* tsg = (rdpTsg*) bio->ptr;
|
rdpTsg* tsg = (rdpTsg*) bio->ptr;
|
||||||
|
|
||||||
BIO_clear_flags(bio, BIO_FLAGS_WRITE);
|
BIO_clear_flags(bio, BIO_FLAGS_WRITE);
|
||||||
|
|
||||||
status = tsg_write(tsg, (BYTE*) buf, num);
|
status = tsg_write(tsg, (BYTE*) buf, num);
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
@ -148,9 +178,7 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
rdpTsg* tsg = (rdpTsg*) bio->ptr;
|
rdpTsg* tsg = (rdpTsg*) bio->ptr;
|
||||||
|
|
||||||
BIO_clear_flags(bio, BIO_FLAGS_READ);
|
BIO_clear_flags(bio, BIO_FLAGS_READ);
|
||||||
|
|
||||||
status = tsg_read(tsg, (BYTE*) buf, size);
|
status = tsg_read(tsg, (BYTE*) buf, size);
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
@ -365,7 +393,6 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
|
|||||||
rdpSettings* settings = transport->settings;
|
rdpSettings* settings = transport->settings;
|
||||||
instance = (freerdp*) transport->settings->instance;
|
instance = (freerdp*) transport->settings->instance;
|
||||||
context = instance->context;
|
context = instance->context;
|
||||||
|
|
||||||
tsg = tsg_new(transport);
|
tsg = tsg_new(transport);
|
||||||
|
|
||||||
if (!tsg)
|
if (!tsg)
|
||||||
@ -1111,13 +1138,10 @@ static void* transport_client_thread(void* arg)
|
|||||||
rdpTransport* transport = (rdpTransport*) arg;
|
rdpTransport* transport = (rdpTransport*) arg;
|
||||||
rdpContext* context = transport->context;
|
rdpContext* context = transport->context;
|
||||||
freerdp* instance = context->instance;
|
freerdp* instance = context->instance;
|
||||||
|
|
||||||
WLog_Print(transport->log, WLOG_DEBUG, "Starting transport thread");
|
WLog_Print(transport->log, WLOG_DEBUG, "Starting transport thread");
|
||||||
|
|
||||||
nCount = 0;
|
nCount = 0;
|
||||||
handles[nCount++] = transport->stopEvent;
|
handles[nCount++] = transport->stopEvent;
|
||||||
handles[nCount++] = transport->connectedEvent;
|
handles[nCount++] = transport->connectedEvent;
|
||||||
|
|
||||||
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE);
|
||||||
|
|
||||||
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
|
if (WaitForSingleObject(transport->stopEvent, 0) == WAIT_OBJECT_0)
|
||||||
@ -1161,7 +1185,6 @@ static void* transport_client_thread(void* arg)
|
|||||||
rdpTransport* transport_new(rdpContext* context)
|
rdpTransport* transport_new(rdpContext* context)
|
||||||
{
|
{
|
||||||
rdpTransport* transport;
|
rdpTransport* transport;
|
||||||
|
|
||||||
transport = (rdpTransport*) calloc(1, sizeof(rdpTransport));
|
transport = (rdpTransport*) calloc(1, sizeof(rdpTransport));
|
||||||
|
|
||||||
if (!transport)
|
if (!transport)
|
||||||
@ -1169,7 +1192,6 @@ rdpTransport* transport_new(rdpContext* context)
|
|||||||
|
|
||||||
transport->context = context;
|
transport->context = context;
|
||||||
transport->settings = context->settings;
|
transport->settings = context->settings;
|
||||||
|
|
||||||
WLog_Init();
|
WLog_Init();
|
||||||
transport->log = WLog_Get(TAG);
|
transport->log = WLog_Get(TAG);
|
||||||
|
|
||||||
@ -1237,13 +1259,10 @@ void transport_free(rdpTransport* transport)
|
|||||||
if (!transport)
|
if (!transport)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
transport_stop(transport);
|
transport_disconnect(transport);
|
||||||
|
|
||||||
if (transport->tsg)
|
if (transport->TcpIn)
|
||||||
{
|
freerdp_tcp_free(transport->TcpIn);
|
||||||
tsg_free(transport->tsg);
|
|
||||||
transport->tsg = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transport->ReceiveBuffer)
|
if (transport->ReceiveBuffer)
|
||||||
Stream_Release(transport->ReceiveBuffer);
|
Stream_Release(transport->ReceiveBuffer);
|
||||||
@ -1251,33 +1270,7 @@ void transport_free(rdpTransport* transport)
|
|||||||
StreamPool_Free(transport->ReceivePool);
|
StreamPool_Free(transport->ReceivePool);
|
||||||
CloseHandle(transport->ReceiveEvent);
|
CloseHandle(transport->ReceiveEvent);
|
||||||
CloseHandle(transport->connectedEvent);
|
CloseHandle(transport->connectedEvent);
|
||||||
|
|
||||||
if (transport->TlsIn)
|
|
||||||
tls_free(transport->TlsIn);
|
|
||||||
|
|
||||||
if (transport->TlsOut != transport->TlsIn)
|
|
||||||
tls_free(transport->TlsOut);
|
|
||||||
|
|
||||||
transport->TlsIn = NULL;
|
|
||||||
transport->TlsOut = NULL;
|
|
||||||
|
|
||||||
if (transport->TcpIn)
|
|
||||||
freerdp_tcp_free(transport->TcpIn);
|
|
||||||
|
|
||||||
if (transport->TcpOut != transport->TcpIn)
|
|
||||||
freerdp_tcp_free(transport->TcpOut);
|
|
||||||
|
|
||||||
transport->TcpIn = NULL;
|
|
||||||
transport->TcpOut = NULL;
|
|
||||||
|
|
||||||
if (transport->TsgTls)
|
|
||||||
{
|
|
||||||
tls_free(transport->TsgTls);
|
|
||||||
transport->TsgTls = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteCriticalSection(&(transport->ReadLock));
|
DeleteCriticalSection(&(transport->ReadLock));
|
||||||
DeleteCriticalSection(&(transport->WriteLock));
|
DeleteCriticalSection(&(transport->WriteLock));
|
||||||
|
|
||||||
free(transport);
|
free(transport);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user