summaryrefslogtreecommitdiff
path: root/http-internal.h
diff options
context:
space:
mode:
authorAzat Khuzhin <azat@libevent.org>2019-03-04 06:53:42 +0300
committerAzat Khuzhin <azat@libevent.org>2019-03-05 00:33:46 +0300
commit5ee507c889b019e9296f48e4f133c439e3040c9e (patch)
treed48a22fa5a3a78c051f25e0221aab9caad0d0831 /http-internal.h
parent62df1301ca943011fa9c398323049bcddca2694d (diff)
downloadlibevent-5ee507c889b019e9296f48e4f133c439e3040c9e.tar.gz
http: implement separate timeouts for read/write/connect phase
This patch allows to change timeout for next events read/write/connect separatelly, using new API: - client: evhttp_connection_set_connect_timeout_tv() -- for connect evhttp_connection_set_read_timeout_tv() -- for read evhttp_connection_set_write_timeout_tv() -- for write - server: evhttp_set_read_timeout_tv() -- for read evhttp_set_write_timeout_tv() -- for write It also changes a logic a little, before there was next fallbacks which does not handled in new API: - HTTP_CONNECT_TIMEOUT - HTTP_WRITE_TIMEOUT - HTTP_READ_TIMEOUT And introduce another internal flag (EVHTTP_CON_TIMEOUT_ADJUSTED) that will be used in evrpc, which adjust evhttp_connection timeout only if it is not default. Fixes: #692 Fixes: #715
Diffstat (limited to 'http-internal.h')
-rw-r--r--http-internal.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/http-internal.h b/http-internal.h
index 9e5b0f95..fb39a650 100644
--- a/http-internal.h
+++ b/http-internal.h
@@ -17,6 +17,7 @@
#define HTTP_CONNECT_TIMEOUT 45
#define HTTP_WRITE_TIMEOUT 50
#define HTTP_READ_TIMEOUT 50
+#define HTTP_INITIAL_RETRY_TIMEOUT 2
#define HTTP_PREFIX "http://"
#define HTTP_DEFAULTPORT 80
@@ -79,8 +80,13 @@ struct evhttp_connection {
/* Installed when attempt to read HTTP error after write failed, see
* EVHTTP_CON_READ_ON_WRITE_ERROR */
#define EVHTTP_CON_READING_ERROR (EVHTTP_CON_AUTOFREE << 1)
+/* Timeout is not default */
+#define EVHTTP_CON_TIMEOUT_ADJUSTED (EVHTTP_CON_READING_ERROR << 1)
+
+ struct timeval timeout_connect; /* timeout for connect phase */
+ struct timeval timeout_read; /* timeout for read */
+ struct timeval timeout_write; /* timeout for write */
- struct timeval timeout; /* timeout for events */
int retry_cnt; /* retry count */
int retry_max; /* maximum number of retries */
struct timeval initial_retry_timeout; /* Timeout for low long to wait
@@ -153,7 +159,8 @@ struct evhttp {
/* NULL if this server is not a vhost */
char *vhost_pattern;
- struct timeval timeout;
+ struct timeval timeout_read; /* timeout for read */
+ struct timeval timeout_write; /* timeout for write */
size_t default_max_headers_size;
ev_uint64_t default_max_body_size;