[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:
Armin Novak 2022-11-30 14:59:28 +01:00 committed by akallabeth
parent 2809e14064
commit 5f81005ecb
7 changed files with 47 additions and 93 deletions

View File

@ -3908,19 +3908,6 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
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")
{
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl,

View File

@ -536,7 +536,6 @@ typedef struct
#define FreeRDP_Domain (23)
#define FreeRDP_PasswordHash (24)
#define FreeRDP_WaitForOutputBufferFlush (25)
#define FreeRDP_MaxTimeInCheckLoop (26)
#define FreeRDP_AcceptedCert (27)
#define FreeRDP_AcceptedCertLength (28)
#define FreeRDP_UserSpecifiedServerName (29)
@ -984,7 +983,7 @@ struct rdp_settings
ALIGN64 char* Domain; /* 23 */
ALIGN64 char* PasswordHash; /* 24 */
ALIGN64 BOOL WaitForOutputBufferFlush; /* 25 */
ALIGN64 UINT32 MaxTimeInCheckLoop; /* 26 */
UINT64 padding26[27 - 26]; /* 26 */
ALIGN64 char* AcceptedCert; /* 27 */
ALIGN64 UINT32 AcceptedCertLength; /* 28 */
ALIGN64 char* UserSpecifiedServerName; /* 29 */

View File

@ -1628,9 +1628,6 @@ UINT32 freerdp_settings_get_uint32(const rdpSettings* settings, size_t id)
case FreeRDP_LoadBalanceInfoLength:
return settings->LoadBalanceInfoLength;
case FreeRDP_MaxTimeInCheckLoop:
return settings->MaxTimeInCheckLoop;
case FreeRDP_MonitorAttributeFlags:
return settings->MonitorAttributeFlags;
@ -2070,10 +2067,6 @@ BOOL freerdp_settings_set_uint32(rdpSettings* settings, size_t id, UINT32 val)
settings->LoadBalanceInfoLength = cnv.c;
break;
case FreeRDP_MaxTimeInCheckLoop:
settings->MaxTimeInCheckLoop = cnv.c;
break;
case FreeRDP_MonitorAttributeFlags:
settings->MonitorAttributeFlags = cnv.c;
break;

View File

@ -324,7 +324,6 @@ static const struct settings_str_entry settings_map[] = {
{ FreeRDP_LargePointerFlag, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_LargePointerFlag" },
{ FreeRDP_LoadBalanceInfoLength, FREERDP_SETTINGS_TYPE_UINT32,
"FreeRDP_LoadBalanceInfoLength" },
{ FreeRDP_MaxTimeInCheckLoop, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_MaxTimeInCheckLoop" },
{ FreeRDP_MonitorAttributeFlags, FREERDP_SETTINGS_TYPE_UINT32,
"FreeRDP_MonitorAttributeFlags" },
{ FreeRDP_MonitorCount, FREERDP_SETTINGS_TYPE_UINT32, "FreeRDP_MonitorCount" },

View File

@ -379,7 +379,6 @@ rdpSettings* freerdp_settings_new(DWORD flags)
!freerdp_settings_set_bool(settings, FreeRDP_WaitForOutputBufferFlush, TRUE) ||
!freerdp_settings_set_uint32(settings, FreeRDP_ClusterInfoFlags,
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_DesktopHeight, 768) ||
!freerdp_settings_set_bool(settings, FreeRDP_Workarea, FALSE) ||

View File

@ -254,7 +254,6 @@ static const size_t uint32_list_indices[] = {
FreeRDP_KeyboardType,
FreeRDP_LargePointerFlag,
FreeRDP_LoadBalanceInfoLength,
FreeRDP_MaxTimeInCheckLoop,
FreeRDP_MonitorAttributeFlags,
FreeRDP_MonitorCount,
FreeRDP_MonitorDefArraySize,

View File

@ -1118,8 +1118,6 @@ int transport_check_fds(rdpTransport* transport)
int status;
state_run_t recv_status;
wStream* received;
UINT64 now = GetTickCount64();
UINT64 dueDate = 0;
rdpContext* context = transport_get_context(transport);
WINPR_ASSERT(context);
@ -1131,23 +1129,6 @@ int transport_check_fds(rdpTransport* transport)
return -1;
}
WINPR_ASSERT(context->settings);
dueDate = now + context->settings->MaxTimeInCheckLoop;
if (transport->haveMoreBytesToRead)
{
transport->haveMoreBytesToRead = FALSE;
ResetEvent(transport->rereadEvent);
}
while (now < dueDate)
{
WINPR_ASSERT(context);
if (freerdp_shall_disconnect_context(context))
{
return -1;
}
/**
* Note: transport_read_pdu tries to read one PDU from
* the transport layer.
@ -1160,9 +1141,13 @@ int transport_check_fds(rdpTransport* transport)
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);
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;
}
@ -1181,12 +1166,6 @@ int transport_check_fds(rdpTransport* transport)
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 };
@ -1196,16 +1175,15 @@ int transport_check_fds(rdpTransport* transport)
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;
SetEvent(transport->rereadEvent);
}
return 0;
return recv_status;
}
BOOL transport_set_blocking_mode(rdpTransport* transport, BOOL blocking)