diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2015-01-16 11:21:02 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-01-18 01:41:26 +0100 |
commit | 6c222d0646fa7c07be96d729009916d5af295332 (patch) | |
tree | 3e9ea61840825fee44d1fd562cd08ca6b1eceb69 /uclient-http.c | |
parent | 71ca932167085f313711d4259393c5f3441cc3a8 (diff) | |
download | uclient-6c222d0646fa7c07be96d729009916d5af295332.tar.gz |
support for connection timeout
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Diffstat (limited to 'uclient-http.c')
-rw-r--r-- | uclient-http.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/uclient-http.c b/uclient-http.c index c25e52f..af43b05 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -689,8 +689,13 @@ static void __uclient_notify_read(struct uclient_http *uh) if (uh->eof) return; - if (uh->state == HTTP_STATE_RECV_DATA && uc->cb->data_read) - uc->cb->data_read(uc); + if (uh->state == HTTP_STATE_RECV_DATA) { + /* Now it's uclient user turn to read some data */ + uloop_timeout_cancel(&uc->connection_timeout); + + if (uc->cb->data_read) + uc->cb->data_read(uc); + } } static void __uclient_notify_write(struct uclient_http *uh) @@ -1030,6 +1035,10 @@ uclient_http_read(struct uclient *cl, char *buf, unsigned int len) uclient_notify_eof(uh); + /* Now that we consumed something and if this isn't EOF, start timer again */ + if (!uh->uc.eof && !cl->connection_timeout.pending) + uloop_timeout_set(&cl->connection_timeout, cl->timeout_msecs); + return len; } |