mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2025-06-03 00:00:20 +00:00
server/proxy: Fix double-call to disconnect
This commit is contained in:
parent
ba6d386998
commit
c0cece1064
@ -183,8 +183,6 @@ static void pf_client_post_disconnect(freerdp* instance)
|
|||||||
{
|
{
|
||||||
pClientContext* context;
|
pClientContext* context;
|
||||||
proxyData* pdata;
|
proxyData* pdata;
|
||||||
rdpContext* ps;
|
|
||||||
freerdp_peer* peer;
|
|
||||||
|
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
@ -194,8 +192,6 @@ static void pf_client_post_disconnect(freerdp* instance)
|
|||||||
|
|
||||||
context = (pClientContext*) instance->context;
|
context = (pClientContext*) instance->context;
|
||||||
pdata = context->pdata;
|
pdata = context->pdata;
|
||||||
ps = (rdpContext*) pdata->ps;
|
|
||||||
peer = ps->peer;
|
|
||||||
|
|
||||||
PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
|
PubSub_UnsubscribeChannelConnected(instance->context->pubSub,
|
||||||
pf_OnChannelConnectedEventHandler);
|
pf_OnChannelConnectedEventHandler);
|
||||||
@ -204,13 +200,7 @@ static void pf_client_post_disconnect(freerdp* instance)
|
|||||||
PubSub_UnsubscribeErrorInfo(instance->context->pubSub, pf_OnErrorInfo);
|
PubSub_UnsubscribeErrorInfo(instance->context->pubSub, pf_OnErrorInfo);
|
||||||
gdi_free(instance);
|
gdi_free(instance);
|
||||||
|
|
||||||
if (!pf_common_connection_aborted_by_peer(pdata))
|
|
||||||
{
|
|
||||||
SetEvent(pdata->connectionClosed);
|
SetEvent(pdata->connectionClosed);
|
||||||
WLog_INFO(TAG, "connectionClosed event is not set; closing connection with client");
|
|
||||||
peer->Disconnect(peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* It's important to avoid calling `freerdp_peer_context_free` and `freerdp_peer_free` here,
|
/* It's important to avoid calling `freerdp_peer_context_free` and `freerdp_peer_free` here,
|
||||||
* in order to avoid double-free. Those objects will be freed by the server when needed.
|
* in order to avoid double-free. Those objects will be freed by the server when needed.
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +61,7 @@ static void pf_server_handle_client_disconnection(freerdp_peer* client)
|
|||||||
ps = (pServerContext*)client->context;
|
ps = (pServerContext*)client->context;
|
||||||
pc = (rdpContext*) ps->pdata->pc;
|
pc = (rdpContext*) ps->pdata->pc;
|
||||||
pdata = ps->pdata;
|
pdata = ps->pdata;
|
||||||
WLog_INFO(TAG, "Client %s disconnected; closing connection with server %s",
|
WLog_INFO(TAG, "Client %s disconnected; closing proxy's client <> target server connection %s",
|
||||||
client->hostname, pc->settings->ServerHostname);
|
client->hostname, pc->settings->ServerHostname);
|
||||||
/* Mark connection closed for sContext */
|
/* Mark connection closed for sContext */
|
||||||
SetEvent(pdata->connectionClosed);
|
SetEvent(pdata->connectionClosed);
|
||||||
@ -298,19 +298,22 @@ static DWORD WINAPI pf_server_handle_client(LPVOID arg)
|
|||||||
eventCount += tmp;
|
eventCount += tmp;
|
||||||
}
|
}
|
||||||
eventHandles[eventCount++] = ChannelEvent;
|
eventHandles[eventCount++] = ChannelEvent;
|
||||||
|
eventHandles[eventCount++] = pdata->connectionClosed;
|
||||||
eventHandles[eventCount++] = WTSVirtualChannelManagerGetEventHandle(ps->vcm);
|
eventHandles[eventCount++] = WTSVirtualChannelManagerGetEventHandle(ps->vcm);
|
||||||
status = WaitForMultipleObjects(eventCount, eventHandles, FALSE, INFINITE);
|
status = WaitForMultipleObjects(eventCount, eventHandles, FALSE, INFINITE);
|
||||||
|
|
||||||
if (status == WAIT_FAILED)
|
if (status == WAIT_FAILED)
|
||||||
{
|
{
|
||||||
/* Ignore wait fails that are caused by legitimate client disconnections */
|
|
||||||
if (pf_common_connection_aborted_by_peer(pdata))
|
|
||||||
break;
|
|
||||||
|
|
||||||
WLog_ERR(TAG, "WaitForMultipleObjects failed (errno: %d)", errno);
|
WLog_ERR(TAG, "WaitForMultipleObjects failed (errno: %d)", errno);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pf_common_connection_aborted_by_peer(pdata))
|
||||||
|
{
|
||||||
|
WLog_INFO(TAG, "proxy's client disconnected, closing connection with client %s", client->hostname);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (client->CheckFileDescriptor(client) != TRUE)
|
if (client->CheckFileDescriptor(client) != TRUE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user