summaryrefslogtreecommitdiffhomepage
path: root/src/reqs.c
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-14 21:59:27 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-15 23:12:00 +0100
commit0c8275a90ed16c4230fb311aebbf34c5667667c7 (patch)
treea3b8db70e0acdeff76fd0b04b9bc4e0745b76b42 /src/reqs.c
parent5779ba8697f16afa2b8fe042a409f192161b7706 (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.c12
1 files changed, 5 insertions, 7 deletions
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
}