parent
0866539493
commit
84b4d2cdb5
|
@ -76,17 +76,11 @@ static void connection_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents
|
|||
static int on_message_begin(http_parser *parser)
|
||||
{
|
||||
struct uh_connection *con = container_of(parser, struct uh_connection, parser);
|
||||
struct ev_loop *loop = con->srv->loop;
|
||||
ev_timer *timer_watcher = &con->timer_watcher;
|
||||
|
||||
uh_buf_init(&con->read_buf, UH_BUFFER_SIZE);
|
||||
uh_buf_init(&con->write_buf, UH_BUFFER_SIZE);
|
||||
|
||||
memset(&con->req, 0, sizeof(struct uh_request));
|
||||
|
||||
ev_timer_stop(loop, timer_watcher);
|
||||
ev_timer_init(timer_watcher, connection_timeout_cb, UH_CONNECTION_TIMEOUT, 0);
|
||||
ev_timer_start(loop, timer_watcher);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -232,6 +226,8 @@ handshake_done:
|
|||
uh_log_err("http parser failed:%s", http_errno_description(HTTP_PARSER_ERRNO(&con->parser)));
|
||||
uh_send_error(con, 400, NULL);
|
||||
}
|
||||
|
||||
ev_timer_mode(loop, &con->timer_watcher, UH_CONNECTION_TIMEOUT, 0);
|
||||
}
|
||||
|
||||
static void connection_write_cb(struct ev_loop *loop, ev_io *w, int revents)
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
#define likely(x) (__builtin_expect(!!(x), 1))
|
||||
#define unlikely(x) (__builtin_expect(!!(x), 0))
|
||||
|
||||
#define ev_timer_mode(l,w,after,repeat) do { \
|
||||
ev_timer_stop(l, w); \
|
||||
ev_timer_init(w, ev_cb(w), after, repeat); \
|
||||
ev_timer_start(l, w); \
|
||||
} while (0)
|
||||
|
||||
struct uh_route {
|
||||
char *path;
|
||||
uh_route_handler_t cb;
|
||||
|
|
Loading…
Reference in New Issue