chibipub

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit daf2460bd760556adebaa5c4865ad5f9d5d2808f
parent 06e0c41cd059bfb0c1e16ccf59047b559564b6af
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 19 Nov 2020 13:27:43 -0800

reset parser on each client request

Diffstat:
Msrc/wolfsocks.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/wolfsocks.c b/src/wolfsocks.c @@ -38,15 +38,11 @@ void run_http_server() int optval; struct http_req req; - memset(&req, 0, sizeof(req)); struct parser parser; const int port = 5188; - make_cursor(buffer, buffer + BUF_SIZE, &parser.cur); - make_cursor(arena, arena + ARENA_SIZE, &parser.arena); - if ((parent = socket(AF_INET, SOCK_STREAM, 0)) < 0) { error("socket"); } @@ -73,6 +69,10 @@ void run_http_server() client_len = sizeof(client_addr); while (1) { + memset(&req, 0, sizeof(req)); + make_cursor(buffer, buffer + BUF_SIZE, &parser.cur); + make_cursor(arena, arena + ARENA_SIZE, &parser.arena); + client = accept(parent, (struct sockaddr *) &client_addr, &client_len); if (client < 0) {