diff --git a/httpserver.h b/httpserver.h index 92787b0..bbf9150 100644 --- a/httpserver.h +++ b/httpserver.h @@ -525,6 +525,7 @@ void hs_server_init(struct http_server_s* serv); void hs_delete_events(struct http_request_s* request); void hs_add_events(struct http_request_s* request); void hs_add_write_event(struct http_request_s* request); +void hs_add_read_event(struct http_request_s* request); void hs_process_tokens(http_request_t* request); #ifdef KQUEUE @@ -1093,6 +1094,7 @@ void hs_write_response(http_request_t* request) { request->state = HTTP_SESSION_INIT; hs_free_buffer(request); hs_reset_timeout(request, HTTP_KEEP_ALIVE_TIMEOUT); + hs_add_read_event(request); } else { HTTP_FLAG_SET(request->flags, HTTP_END_SESSION); } @@ -1457,7 +1459,7 @@ void grwprintf(grwprintf_t* ctx, char const * fmt, ...) { *ctx->memused += ctx->capacity; ctx->buf = (char*)realloc(ctx->buf, ctx->capacity); assert(ctx->buf != NULL); - bytes += vsnprintf(ctx->buf + ctx->size, ctx->capacity - ctx->size, fmt, args); + bytes = vsnprintf(ctx->buf + ctx->size, ctx->capacity - ctx->size, fmt, args); } ctx->size += bytes; @@ -1754,6 +1756,13 @@ void hs_add_write_event(http_request_t* request) { epoll_ctl(request->server->loop, EPOLL_CTL_MOD, request->socket, &ev); } +void hs_add_read_event(http_request_t* request) { + struct epoll_event ev; + ev.events = EPOLLIN | EPOLLET; + ev.data.ptr = request; + epoll_ctl(request->server->loop, EPOLL_CTL_MOD, request->socket, &ev); +} + #endif #endif