diff options
author | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-14 21:59:27 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-15 23:12:00 +0100 |
commit | 0c8275a90ed16c4230fb311aebbf34c5667667c7 (patch) | |
tree | a3b8db70e0acdeff76fd0b04b9bc4e0745b76b42 /src/reqs.c | |
parent | 5779ba8697f16afa2b8fe042a409f192161b7706 (diff) |
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.
Diffstat (limited to 'src/reqs.c')
-rw-r--r-- | src/reqs.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -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 } |