Slon/Http/Server: Set SLON_HTTP_REQUEST_TIMEOUT at 3000 ms
This commit is contained in:
parent
2dc8eac296
commit
497a05f183
1 changed files with 18 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
#define SLON_DEBUG_PRINT_REQUEST_JSON IntNop;
|
#define SLON_DEBUG_PRINT_REQUEST_JSON IntNop;
|
||||||
|
#define SLON_HTTP_REQUEST_TIMEOUT 3000
|
||||||
|
|
||||||
SlonHttpBuffer* @slon_http_init_buffer(SlonHttpSession* session)
|
SlonHttpBuffer* @slon_http_init_buffer(SlonHttpSession* session)
|
||||||
{
|
{
|
||||||
|
@ -809,12 +810,15 @@ U0 @slon_http_handle_request(SlonHttpSession* session)
|
||||||
U0 @slon_http_task(TcpSocket* s)
|
U0 @slon_http_task(TcpSocket* s)
|
||||||
{
|
{
|
||||||
// Bail if we can't acquire socket for some reason
|
// Bail if we can't acquire socket for some reason
|
||||||
if (!@tcp_socket_accept(s))
|
if (!@tcp_socket_accept(s)) {
|
||||||
return;
|
Kill(Fs);
|
||||||
|
}
|
||||||
|
|
||||||
// Init session
|
// Init session
|
||||||
SlonHttpSession* session = @slon_http_init_session(s);
|
SlonHttpSession* session = @slon_http_init_session(s);
|
||||||
|
|
||||||
|
I64 start_jiffies = cnts.jiffies;
|
||||||
|
|
||||||
// Parse headers if they are available
|
// Parse headers if they are available
|
||||||
while (!@slon_http_request_headers_have_been_parsed(session)) {
|
while (!@slon_http_request_headers_have_been_parsed(session)) {
|
||||||
@slon_http_receive(session);
|
@slon_http_receive(session);
|
||||||
|
@ -826,6 +830,11 @@ U0 @slon_http_task(TcpSocket* s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@slon_http_try_parse_request_headers(session);
|
@slon_http_try_parse_request_headers(session);
|
||||||
|
|
||||||
|
if (cnts.jiffies > start_jiffies + SLON_HTTP_REQUEST_TIMEOUT) {
|
||||||
|
s->close();
|
||||||
|
Kill(Fs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@slon_http_debug_print_request(session, FALSE);
|
//@slon_http_debug_print_request(session, FALSE);
|
||||||
|
@ -833,8 +842,14 @@ U0 @slon_http_task(TcpSocket* s)
|
||||||
// If we have a content-length header, consume until we receive all the data, then set request->data pointer and size
|
// If we have a content-length header, consume until we receive all the data, then set request->data pointer and size
|
||||||
if (StrLen(session->header("content-length"))) {
|
if (StrLen(session->header("content-length"))) {
|
||||||
I64 content_length = Str2I64(session->header("content-length"));
|
I64 content_length = Str2I64(session->header("content-length"));
|
||||||
while (session->request->buffer->data + session->request->buffer->size - session->request->data < content_length)
|
start_jiffies = cnts.jiffies;
|
||||||
|
while (session->request->buffer->data + session->request->buffer->size - session->request->data < content_length) {
|
||||||
@slon_http_receive(session);
|
@slon_http_receive(session);
|
||||||
|
if (cnts.jiffies > start_jiffies + SLON_HTTP_REQUEST_TIMEOUT) {
|
||||||
|
s->close();
|
||||||
|
Kill(Fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@slon_http_handle_request(session);
|
@slon_http_handle_request(session);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue