diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-19 16:07:15 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-19 16:07:15 +0100 |
commit | 4c6ee39cb985e47c88bd65783ff5385a32c4bd3f (patch) | |
tree | 885c259990a5c1051047a01659c137898d8a11e5 /client.c | |
parent | 74476cc006ea6bd8ccf2bed0474113bdad96de02 (diff) |
poll read data after connect as well
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -92,11 +92,18 @@ static void uh_set_client_timeout(struct client *cl, int timeout) static void uh_keepalive_poll_cb(struct uloop_timeout *timeout) { struct client *cl = container_of(timeout, struct client, timeout); + int sec = cl->requests > 0 ? conf.http_keepalive : conf.network_timeout; - uh_set_client_timeout(cl, conf.http_keepalive); + uh_set_client_timeout(cl, sec); cl->us->notify_read(cl->us, 0); } +static void uh_poll_connection(struct client *cl) +{ + cl->timeout.cb = uh_keepalive_poll_cb; + uloop_timeout_set(&cl->timeout, 1); +} + void uh_request_done(struct client *cl) { uh_chunk_eof(cl); @@ -108,8 +115,8 @@ void uh_request_done(struct client *cl) return uh_connection_close(cl); cl->state = CLIENT_STATE_INIT; - cl->timeout.cb = uh_keepalive_poll_cb; - uloop_timeout_set(&cl->timeout, 1); + cl->requests++; + uh_poll_connection(cl); } void __printf(4, 5) @@ -550,7 +557,7 @@ bool uh_accept_client(int fd, bool tls) cl->us->string_data = true; ustream_fd_init(&cl->sfd, sfd); - uh_set_client_timeout(cl, conf.network_timeout); + uh_poll_connection(cl); list_add_tail(&cl->list, &clients); next_client = NULL; |