fix high cpu usage when handling bad POST request

This commit is contained in:
lxsang
2021-02-04 19:40:02 +01:00
parent d0c917ce99
commit b9bd5e9ad1
2 changed files with 19 additions and 4 deletions

View File

@ -565,6 +565,10 @@ int antd_recv_upto(void *src, void *data, int len)
}
else
{
if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
{
return -1;
}
switch (err)
{
case SSL_ERROR_NONE:
@ -603,6 +607,10 @@ int antd_recv_upto(void *src, void *data, int len)
time(&source->last_io);
return received;
}
else if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
{
return -1;
}
if (received <= 0 && (errno == EAGAIN || errno == EWOULDBLOCK))
{
return 0;