[transport] remove polling loop
We no longer have a blocking polling loop in transport. Instead assume there is more data after a packet was processed and let the transport try again. If there is another packet ready, this repeats until only a partly received (or no new data available) situation is reached.
This commit is contained in:
parent
2809e14064
commit
5f81005ecb
@ -3908,19 +3908,6 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
|||||||
|
|
||||||
settings->MultifragMaxRequestSize = (UINT32)val;
|
settings->MultifragMaxRequestSize = (UINT32)val;
|
||||||
}
|
}
|
||||||
CommandLineSwitchCase(arg, "max-loop-time")
|
|
||||||
{
|
|
||||||
LONGLONG val;
|
|
||||||
|
|
||||||
if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
|
|
||||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
|
||||||
|
|
||||||
if (val < 0)
|
|
||||||
settings->MaxTimeInCheckLoop =
|
|
||||||
10 * 60 * 60 * 1000; /* 10 hours can be considered as infinite */
|
|
||||||
else
|
|
||||||
settings->MaxTimeInCheckLoop = (UINT32)val;
|
|
||||||
}
|
|
||||||
CommandLineSwitchCase(arg, "auto-request-control")
|
CommandLineSwitchCase(arg, "auto-request-control")
|
||||||
{
|
{
|
||||||
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl,
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl,
|
||||||
|
@ -536,7 +536,6 @@ typedef struct
|
|||||||
#define FreeRDP_Domain (23)
|
#define FreeRDP_Domain (23)
|
||||||
#define FreeRDP_PasswordHash (24)
|
#define FreeRDP_PasswordHash (24)
|
||||||
#define FreeRDP_WaitForOutputBufferFlush (25)
|
#define FreeRDP_WaitForOutputBufferFlush (25)
|
||||||
#define FreeRDP_MaxTimeInCheckLoop (26)
|
|
||||||
#define FreeRDP_AcceptedCert (27)
|
#define FreeRDP_AcceptedCert (27)
|
||||||
#define FreeRDP_AcceptedCertLength (28)
|
#define FreeRDP_AcceptedCertLength (28)
|
||||||
#define FreeRDP_UserSpecifiedServerName (29)
|
#define FreeRDP_UserSpecifiedServerName (29)
|
||||||
@ -984,7 +983,7 @@ struct rdp_settings
|
|||||||
ALIGN64 char* Domain; /* 23 */
|
ALIGN64 char* Domain; /* 23 */
|
||||||
ALIGN64 char* PasswordHash; /* 24 */
|
ALIGN64 char* PasswordHash; /* 24 */
|
||||||
ALIGN64 BOOL WaitForOutputBufferFlush; /* 25 */
|
ALIGN64 BOOL WaitForOutputBufferFlush; /* 25 */
|
||||||
ALIGN64 UINT32 MaxTimeInCheckLoop; /* 26 */
|
UINT64 padding26[27 - 26]; /* 26 */
|
||||||
ALIGN64 char* AcceptedCert; /* 27 */
|
ALIGN64 char* AcceptedCert; /* 27 */
|
||||||
ALIGN64 UINT32 AcceptedCertLength; /* 28 */
|
ALIGN64 UINT32 AcceptedCertLength; /* 28 */
|
||||||
ALIGN64 char* UserSpecifiedServerName; /* 29 */
|
ALIGN64 char* UserSpecifiedServerName; /* 29 */
|
||||||
|
@ -1628,9 +1628,6 @@ UINT32 freerdp_settings_get_uint32(const rdpSettings* settings, size_t id)
|
|||||||
case FreeRDP_LoadBalanceInfoLength:
|
case FreeRDP_LoadBalanceInfoLength:
|
||||||
return settings->LoadBalanceInfoLength;
|
return settings->LoadBalanceInfoLength;
|
||||||
|
|
||||||
case FreeRDP_MaxTimeInCheckLoop:
|
|
||||||
return settings->MaxTimeInCheckLoop;
|
|
||||||
|
|
||||||
case FreeRDP_MonitorAttributeFlags:
|
case FreeRDP_MonitorAttributeFlags:
|
||||||
return settings->MonitorAttributeFlags;
|
return settings->MonitorAttributeFlags;
|
||||||
|
|
||||||
@ -2070,10 +2067,6 @@ BOOL freerdp_settings_set_uint32(rdpSettings* settings, size_t id, UINT32 val)
|
|||||||
settings->LoadBalanceInfoLength = cnv.c;
|
settings->LoadBalanceInfoLength = cnv.c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FreeRDP_MaxTimeInCheckLoop:
|
|
||||||
settings->MaxTimeInCheckLoop = cnv.c;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FreeRDP_MonitorAttributeFlags:
|
case FreeRDP_MonitorAttributeFlags:
|
||||||
settings->MonitorAttributeFlags = cnv.c;
|
settings->MonitorAttributeFlags = cnv.c;
|
||||||
break;
|
break;
|
||||||
|
@ -324,7 +324,6 @@ static const struct settings_str_entry settings_map[] = {
|
|||||||
{ FreeRDP_LargePointerFlag, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_LargePointerFlag" },
|
{ FreeRDP_LargePointerFlag, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_LargePointerFlag" },
|
||||||
{ FreeRDP_LoadBalanceInfoLength, FREERDP_SETTINGS_TYPE_UINT32,
|
{ FreeRDP_LoadBalanceInfoLength, FREERDP_SETTINGS_TYPE_UINT32,
|
||||||
"FreeRDP_LoadBalanceInfoLength" },
|
"FreeRDP_LoadBalanceInfoLength" },
|
||||||
{ FreeRDP_MaxTimeInCheckLoop, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_MaxTimeInCheckLoop" },
|
|
||||||
{ FreeRDP_MonitorAttributeFlags, FREERDP_SETTINGS_TYPE_UINT32,
|
{ FreeRDP_MonitorAttributeFlags, FREERDP_SETTINGS_TYPE_UINT32,
|
||||||
"FreeRDP_MonitorAttributeFlags" },
|
"FreeRDP_MonitorAttributeFlags" },
|
||||||
{ FreeRDP_MonitorCount, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_MonitorCount" },
|
{ FreeRDP_MonitorCount, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_MonitorCount" },
|
||||||
|
@ -379,7 +379,6 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
|||||||
!freerdp_settings_set_bool(settings, FreeRDP_WaitForOutputBufferFlush, TRUE) ||
|
!freerdp_settings_set_bool(settings, FreeRDP_WaitForOutputBufferFlush, TRUE) ||
|
||||||
!freerdp_settings_set_uint32(settings, FreeRDP_ClusterInfoFlags,
|
!freerdp_settings_set_uint32(settings, FreeRDP_ClusterInfoFlags,
|
||||||
REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2)) ||
|
REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2)) ||
|
||||||
!freerdp_settings_set_uint32(settings, FreeRDP_MaxTimeInCheckLoop, 100) ||
|
|
||||||
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1024) ||
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopWidth, 1024) ||
|
||||||
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 768) ||
|
!freerdp_settings_set_uint32(settings, FreeRDP_DesktopHeight, 768) ||
|
||||||
!freerdp_settings_set_bool(settings, FreeRDP_Workarea, FALSE) ||
|
!freerdp_settings_set_bool(settings, FreeRDP_Workarea, FALSE) ||
|
||||||
|
@ -254,7 +254,6 @@ static const size_t uint32_list_indices[] = {
|
|||||||
FreeRDP_KeyboardType,
|
FreeRDP_KeyboardType,
|
||||||
FreeRDP_LargePointerFlag,
|
FreeRDP_LargePointerFlag,
|
||||||
FreeRDP_LoadBalanceInfoLength,
|
FreeRDP_LoadBalanceInfoLength,
|
||||||
FreeRDP_MaxTimeInCheckLoop,
|
|
||||||
FreeRDP_MonitorAttributeFlags,
|
FreeRDP_MonitorAttributeFlags,
|
||||||
FreeRDP_MonitorCount,
|
FreeRDP_MonitorCount,
|
||||||
FreeRDP_MonitorDefArraySize,
|
FreeRDP_MonitorDefArraySize,
|
||||||
|
@ -1118,8 +1118,6 @@ int transport_check_fds(rdpTransport* transport)
|
|||||||
int status;
|
int status;
|
||||||
state_run_t recv_status;
|
state_run_t recv_status;
|
||||||
wStream* received;
|
wStream* received;
|
||||||
UINT64 now = GetTickCount64();
|
|
||||||
UINT64 dueDate = 0;
|
|
||||||
rdpContext* context = transport_get_context(transport);
|
rdpContext* context = transport_get_context(transport);
|
||||||
|
|
||||||
WINPR_ASSERT(context);
|
WINPR_ASSERT(context);
|
||||||
@ -1131,81 +1129,61 @@ int transport_check_fds(rdpTransport* transport)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINPR_ASSERT(context->settings);
|
/**
|
||||||
dueDate = now + context->settings->MaxTimeInCheckLoop;
|
* Note: transport_read_pdu tries to read one PDU from
|
||||||
|
* the transport layer.
|
||||||
if (transport->haveMoreBytesToRead)
|
* The ReceiveBuffer might have a position > 0 in case of a non blocking
|
||||||
|
* transport. If transport_read_pdu returns 0 the pdu couldn't be read at
|
||||||
|
* this point.
|
||||||
|
* Note that transport->ReceiveBuffer is replaced after each iteration
|
||||||
|
* of this loop with a fresh stream instance from a pool.
|
||||||
|
*/
|
||||||
|
if ((status = transport_read_pdu(transport, transport->ReceiveBuffer)) <= 0)
|
||||||
{
|
{
|
||||||
transport->haveMoreBytesToRead = FALSE;
|
if (status < 0)
|
||||||
ResetEvent(transport->rereadEvent);
|
WLog_Print(transport->log, WLOG_DEBUG, "transport_check_fds: transport_read_pdu() - %i",
|
||||||
|
status);
|
||||||
|
if (transport->haveMoreBytesToRead)
|
||||||
|
{
|
||||||
|
transport->haveMoreBytesToRead = FALSE;
|
||||||
|
ResetEvent(transport->rereadEvent);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (now < dueDate)
|
received = transport->ReceiveBuffer;
|
||||||
|
|
||||||
|
if (!(transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status:
|
||||||
|
* -1: error
|
||||||
|
* 0: success
|
||||||
|
* 1: redirection
|
||||||
|
*/
|
||||||
|
WINPR_ASSERT(transport->ReceiveCallback);
|
||||||
|
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
|
||||||
|
Stream_Release(received);
|
||||||
|
|
||||||
|
if (state_run_failed(recv_status))
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(context);
|
char buffer[64] = { 0 };
|
||||||
if (freerdp_shall_disconnect_context(context))
|
WLog_Print(transport->log, WLOG_ERROR,
|
||||||
{
|
"transport_check_fds: transport->ReceiveCallback() - %s",
|
||||||
return -1;
|
state_run_result_string(recv_status, buffer, ARRAYSIZE(buffer)));
|
||||||
}
|
return -1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Note: transport_read_pdu tries to read one PDU from
|
|
||||||
* the transport layer.
|
|
||||||
* The ReceiveBuffer might have a position > 0 in case of a non blocking
|
|
||||||
* transport. If transport_read_pdu returns 0 the pdu couldn't be read at
|
|
||||||
* this point.
|
|
||||||
* Note that transport->ReceiveBuffer is replaced after each iteration
|
|
||||||
* of this loop with a fresh stream instance from a pool.
|
|
||||||
*/
|
|
||||||
if ((status = transport_read_pdu(transport, transport->ReceiveBuffer)) <= 0)
|
|
||||||
{
|
|
||||||
if (status < 0)
|
|
||||||
WLog_Print(transport->log, WLOG_DEBUG,
|
|
||||||
"transport_check_fds: transport_read_pdu() - %i", status);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
received = transport->ReceiveBuffer;
|
|
||||||
|
|
||||||
if (!(transport->ReceiveBuffer = StreamPool_Take(transport->ReceivePool, 0)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* status:
|
|
||||||
* -1: error
|
|
||||||
* 0: success
|
|
||||||
* 1: redirection
|
|
||||||
*/
|
|
||||||
WINPR_ASSERT(transport->ReceiveCallback);
|
|
||||||
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
|
|
||||||
Stream_Release(received);
|
|
||||||
|
|
||||||
/* session redirection or activation */
|
|
||||||
if (recv_status == STATE_RUN_REDIRECT || recv_status == STATE_RUN_ACTIVE)
|
|
||||||
{
|
|
||||||
return recv_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state_run_failed(recv_status))
|
|
||||||
{
|
|
||||||
char buffer[64] = { 0 };
|
|
||||||
WLog_Print(transport->log, WLOG_ERROR,
|
|
||||||
"transport_check_fds: transport->ReceiveCallback() - %s",
|
|
||||||
state_run_result_string(recv_status, buffer, ARRAYSIZE(buffer)));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
now = GetTickCount64();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now >= dueDate)
|
/* Run this again to be sure we consumed all input data.
|
||||||
|
* This will be repeated until a (not fully) received packet is in buffer
|
||||||
|
*/
|
||||||
|
if (!transport->haveMoreBytesToRead)
|
||||||
{
|
{
|
||||||
SetEvent(transport->rereadEvent);
|
|
||||||
transport->haveMoreBytesToRead = TRUE;
|
transport->haveMoreBytesToRead = TRUE;
|
||||||
|
SetEvent(transport->rereadEvent);
|
||||||
}
|
}
|
||||||
|
return recv_status;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
|
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)
|
||||||
|
Loading…
Reference in New Issue
Block a user