Merge pull request #402 from pjd/disconnect

Graceful exit.
This commit is contained in:
Marc-André Moreau 2012-02-06 18:31:27 -08:00
commit 4117e71a79
8 changed files with 28 additions and 1 deletions

View File

@ -948,7 +948,7 @@ int xfreerdp_run(freerdp* instance)
xfi = ((xfContext*) instance->context)->xfi;
channels = instance->context->channels;
while (!xfi->disconnect)
while (!xfi->disconnect && !freerdp_shall_disconnect(instance))
{
rcount = 0;
wcount = 0;

View File

@ -103,6 +103,7 @@ FREERDP_API void freerdp_context_new(freerdp* instance);
FREERDP_API void freerdp_context_free(freerdp* instance);
FREERDP_API boolean freerdp_connect(freerdp* instance);
FREERDP_API boolean freerdp_shall_disconnect(freerdp* instance);
FREERDP_API boolean freerdp_disconnect(freerdp* instance);
FREERDP_API boolean freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);

View File

@ -294,6 +294,8 @@ boolean rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s)
{
if (rdp_check_fds(rdp) < 0)
return false;
if (rdp->disconnect)
break;
}
return true;

View File

@ -1798,6 +1798,9 @@ boolean rdp_recv_demand_active(rdpRdp* rdp, STREAM* s)
if (!rdp_read_header(rdp, s, &length, &channelId))
return false;
if (rdp->disconnect)
return true;
if (rdp->settings->encryption)
{
rdp_read_security_header(s, &securityFlags);

View File

@ -450,6 +450,9 @@ boolean rdp_client_connect_demand_active(rdpRdp* rdp, STREAM* s)
return true;
}
if (rdp->disconnect)
return true;
if (!rdp_send_confirm_active(rdp))
return false;

View File

@ -147,6 +147,12 @@ boolean freerdp_disconnect(freerdp* instance)
return true;
}
boolean freerdp_shall_disconnect(freerdp* instance)
{
return instance->context->rdp->disconnect;
}
void freerdp_get_version(int* major, int* minor, int* revision)
{
if (major != NULL)

View File

@ -237,6 +237,17 @@ boolean rdp_read_header(rdpRdp* rdp, STREAM* s, uint16* length, uint16* channel_
if (*length - 8 > stream_get_left(s))
return false;
if (MCSPDU == DomainMCSPDU_DisconnectProviderUltimatum)
{
uint8 reason;
(void) per_read_enumerated(s, &reason, 0);
rdp->disconnect = true;
return true;
}
per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
per_read_integer16(s, channel_id, 0); /* channelId */
stream_seek(s, 1); /* dataPriority + Segmentation (0x70) */

View File

@ -155,6 +155,7 @@ struct rdp_rdp
uint8 fips_decrypt_key[24];
uint32 errorInfo;
uint32 finalize_sc_pdus;
boolean disconnect;
};
void rdp_read_security_header(STREAM* s, uint16* flags);