From 0c8275a90ed16c4230fb311aebbf34c5667667c7 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Mon, 14 Sep 2020 21:59:27 +0100 Subject: refactor conns.[ch], put conn_s into child struct this allows to access the conn member from the main thread handling the childs, plus simplifies the code. --- src/reqs.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/reqs.c') diff --git a/src/reqs.c b/src/reqs.c index b962153..2b7649e 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -1509,16 +1509,15 @@ static void handle_connection_failure(struct conn_s *connptr, int got_headers) * tinyproxy code, which was confusing, redundant. Hail progress. * - rjkaes */ -void handle_connection (int fd, union sockaddr_union* addr) +void handle_connection (struct conn_s *connptr, union sockaddr_union* addr) { #define HC_FAIL() \ do {handle_connection_failure(connptr, got_headers); goto done;} \ while(0) - int got_headers = 0; + int got_headers = 0, fd = connptr->client_fd; ssize_t i; - struct conn_s *connptr; struct request_s *request = NULL; struct timeval tv; orderedmap hashofheaders = NULL; @@ -1536,9 +1535,8 @@ void handle_connection (int fd, union sockaddr_union* addr) "Connect (file descriptor %d): %s", fd, peer_ipaddr, sock_ipaddr); - connptr = initialize_conn (fd, peer_ipaddr, - config->bindsame ? sock_ipaddr : NULL); - if (!connptr) { + if(!conn_init_contents (connptr, peer_ipaddr, + config->bindsame ? sock_ipaddr : NULL)) { close (fd); return; } @@ -1739,7 +1737,7 @@ e401: done: free_request_struct (request); orderedmap_destroy (hashofheaders); - destroy_conn (connptr); + conn_destroy_contents (connptr); return; #undef HC_FAIL } -- cgit v1.2.3