mirror of
https://github.com/lxsang/ant-http
synced 2024-11-17 17:08:20 +01:00
fix high cpu usage when handling bad POST request
This commit is contained in:
parent
d0c917ce99
commit
b9bd5e9ad1
@ -877,6 +877,7 @@ static void *proxify(void *data)
|
||||
proxy->ssl = NULL;
|
||||
proxy->zstream = NULL;
|
||||
proxy->z_level = ANTD_CNONE;
|
||||
time(&proxy->last_io);
|
||||
|
||||
// store content length here
|
||||
dput(rq->request, "PROXY_HANDLE", proxy);
|
||||
@ -1177,8 +1178,9 @@ void *decode_post_request(void *data)
|
||||
else if (clen > 0)
|
||||
{
|
||||
// WARN: this may not work on ssl socket
|
||||
antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE | TASK_EVT_ON_WRITABLE);
|
||||
task->handle = decode_post_request;
|
||||
// antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE | TASK_EVT_ON_WRITABLE);
|
||||
// task->handle = decode_post_request;
|
||||
antd_error(rq->client, 400, "Bad Request, missing content data");
|
||||
return task;
|
||||
}
|
||||
}
|
||||
@ -1202,8 +1204,9 @@ void *decode_post_request(void *data)
|
||||
}
|
||||
else if (clen > 0)
|
||||
{
|
||||
task->handle = decode_post_request;
|
||||
antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE | TASK_EVT_ON_WRITABLE);
|
||||
//task->handle = decode_post_request;
|
||||
//antd_task_bind_event(task, rq->client->sock, 0, TASK_EVT_ON_READABLE | TASK_EVT_ON_WRITABLE);
|
||||
antd_error(rq->client, 400, "Bad Request, missing content data");
|
||||
return task;
|
||||
}
|
||||
}
|
||||
@ -1512,6 +1515,10 @@ char *post_data_decode(void *client, int len)
|
||||
read += stat;
|
||||
readlen = (len - read) > BUFFLEN ? BUFFLEN : (len - read);
|
||||
}
|
||||
if (stat == 0)
|
||||
{
|
||||
usleep(POLL_EVENT_TO*1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (read > 0)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user