[core,gateway] use TcpConnectTimeout for read as well
http_response_recv might never receive an answer, so do wait for input and fail if the timeout is exceeded.
This commit is contained in:
parent
02c410c42f
commit
66f31e5bb9
@ -38,6 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "../tcp.h"
|
||||||
|
|
||||||
#define TAG FREERDP_TAG("core.gateway.http")
|
#define TAG FREERDP_TAG("core.gateway.http")
|
||||||
|
|
||||||
@ -1230,14 +1231,34 @@ HttpResponse* http_response_recv(rdpTls* tls, BOOL readContentLength)
|
|||||||
|
|
||||||
response->ContentLength = 0;
|
response->ContentLength = 0;
|
||||||
|
|
||||||
|
const UINT32 timeout = freerdp_settings_get_uint32(tls->settings, FreeRDP_TcpConnectTimeout);
|
||||||
while (payloadOffset == 0)
|
while (payloadOffset == 0)
|
||||||
{
|
{
|
||||||
|
int status = -1;
|
||||||
size_t s = 0;
|
size_t s = 0;
|
||||||
char* end = NULL;
|
char* end = NULL;
|
||||||
/* Read until we encounter \r\n\r\n */
|
/* Read until we encounter \r\n\r\n */
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
int status = BIO_read(tls->bio, Stream_Pointer(response->data), 1);
|
const int wstatus = BIO_wait_read(tls->bio, timeout);
|
||||||
|
if (wstatus < 0)
|
||||||
|
{
|
||||||
|
if (!BIO_should_retry(tls->bio))
|
||||||
|
{
|
||||||
|
WLog_ERR(TAG, "[BIO_wait_read] Retries exceeded");
|
||||||
|
ERR_print_errors_cb(print_bio_error, NULL);
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
USleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (wstatus == 0)
|
||||||
|
{
|
||||||
|
WLog_ERR(TAG, "[BIO_wait] timeout exceeded");
|
||||||
|
ERR_print_errors_cb(print_bio_error, NULL);
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = BIO_read(tls->bio, Stream_Pointer(response->data), 1);
|
||||||
if (status <= 0)
|
if (status <= 0)
|
||||||
{
|
{
|
||||||
if (!BIO_should_retry(tls->bio))
|
if (!BIO_should_retry(tls->bio))
|
||||||
|
Loading…
Reference in New Issue
Block a user