diff mbox series

[uhttpd] client: really close connection on timeout

Message ID 20200923104327.14812-1-zajec5@gmail.com
State Accepted
Headers show
Series [uhttpd] client: really close connection on timeout | expand

Commit Message

Rafał Miłecki Sept. 23, 2020, 10:43 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

After specified time of network inactivity uhttpd is meant to close
connection. It doesn't seem to work thought. After timeout client
doesn't receive any more data but connection it still opened.

This change fixes that.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
V1: Set cl->request.connection_close and then call uh_request_done().
    With this change:
    1. uh_request_done() will take care of calling uh_connection_close()
    2. uh_request_done() won't set state back to the CLIENT_STATE_INIT
 client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/client.c b/client.c
index 2a2393f..b5736e4 100644
--- a/client.c
+++ b/client.c
@@ -95,7 +95,8 @@  static void client_timeout(struct uloop_timeout *timeout)
 	struct client *cl = container_of(timeout, struct client, timeout);
 	cl->state = CLIENT_STATE_CLOSE;
-	uh_connection_close(cl);
+	cl->request.connection_close = true;
+	uh_request_done(cl);
 static void uh_set_client_timeout(struct client *cl, int timeout)