mirror of https://github.com/FreeRDP/FreeRDP
rdpsnd_server_handle_messages: change return type
With BOOL as return type it is not possible to differentiate between success and "no data can be read" (when a channel read would block). rdpsnd_server_handle_messages returns now int with the following possible values: -1 if no data could be read 0 error (like connection close) (formerly FALSE) 1 succsess (also if further bytes need to be read) (formerly TRUE) Not using -1 for error cases was chosen to be compatible with the BOOL return values used before.
This commit is contained in:
parent
e603655048
commit
96cd479c99
|
@ -210,7 +210,7 @@ static void* rdpsnd_server_thread(void* arg)
|
|||
if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
if (!rdpsnd_server_handle_messages(context))
|
||||
if (rdpsnd_server_handle_messages(context) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,16 @@ HANDLE rdpsnd_server_get_event_handle(RdpsndServerContext *context)
|
|||
return context->priv->channelEvent;
|
||||
}
|
||||
|
||||
BOOL rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
||||
/*
|
||||
* Handle rpdsnd messages - server side
|
||||
*
|
||||
* @param Server side context
|
||||
*
|
||||
* @return -1 if no data could be read,
|
||||
* 0 on error (like connection close),
|
||||
* 1 on succsess (also if further bytes need to be read)
|
||||
*/
|
||||
int rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
||||
{
|
||||
DWORD bytesReturned;
|
||||
BOOL ret;
|
||||
|
@ -631,16 +640,16 @@ BOOL rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
|||
if (!WTSVirtualChannelRead(priv->ChannelHandle, 0, (PCHAR)Stream_Pointer(s), priv->expectedBytes, &bytesReturned))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
return TRUE;
|
||||
return -1;
|
||||
|
||||
CLOG_ERR( "%s: channel connection closed\n", __FUNCTION__);
|
||||
return FALSE;
|
||||
return 0;
|
||||
}
|
||||
priv->expectedBytes -= bytesReturned;
|
||||
Stream_Seek(s, bytesReturned);
|
||||
|
||||
if (priv->expectedBytes)
|
||||
return TRUE;
|
||||
return 1;
|
||||
|
||||
Stream_SealLength(s);
|
||||
Stream_SetPosition(s, 0);
|
||||
|
@ -656,7 +665,7 @@ BOOL rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
|||
if (priv->expectedBytes)
|
||||
{
|
||||
Stream_EnsureCapacity(s, priv->expectedBytes);
|
||||
return TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,5 +705,8 @@ BOOL rdpsnd_server_handle_messages(RdpsndServerContext *context)
|
|||
}
|
||||
Stream_SetPosition(s, 0);
|
||||
|
||||
return ret;
|
||||
if (ret)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ FREERDP_API void rdpsnd_server_context_reset(RdpsndServerContext *);
|
|||
FREERDP_API void rdpsnd_server_context_free(RdpsndServerContext* context);
|
||||
FREERDP_API HANDLE rdpsnd_server_get_event_handle(RdpsndServerContext *context);
|
||||
FREERDP_API BOOL rdpsnd_server_handle_messages(RdpsndServerContext *context);
|
||||
FREERDP_API int rdpsnd_server_handle_messages(RdpsndServerContext *context);
|
||||
FREERDP_API BOOL rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue