aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/http.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-06-08 06:23:06 +0000
committerWerner Koch <[email protected]>2017-06-08 07:37:36 +0000
commit5b9025cfa1f9b1c67ddf2f6bf87d863e780cf157 (patch)
treeb0f389c2ff9dc0ea45e4bece3e41bef7a5fa397e /dirmngr/http.h
parentgpg: Avoid failure exit when scdaemon is disabled but not needed. (diff)
downloadgnupg-5b9025cfa1f9b1c67ddf2f6bf87d863e780cf157.tar.gz
gnupg-5b9025cfa1f9b1c67ddf2f6bf87d863e780cf157.zip
dirmngr: Allow a timeout for HTTP and other TCP connects.
* dirmngr/http.c: Include fcntl.h. (http_session_s): Add field 'connect_timeout'. (http_session_new): Clear that. (http_session_set_timeout): New function. (my_wsagetlasterror) [W32]: New. (connect_with_timeout): New function. (connect_server): Add arg 'timeout' and call connect_with_timeout. (send_request): Add arg 'timeout' and pass it to connect_server. (http_raw_connect): Add arg 'timeout'. (http_open): Pass TIMEOUT from the session to connect_server. -- Note that the non-blocking connect we implement is traditional a pretty non-portable thing due to slighly different semantics. The code uses the strategy W. Richard Stevens suggested in 1998. Hopefully current OS versions got it all right. The code has not been tested on Windows. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'dirmngr/http.h')
-rw-r--r--dirmngr/http.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/dirmngr/http.h b/dirmngr/http.h
index 2609b9ede..448cd0430 100644
--- a/dirmngr/http.h
+++ b/dirmngr/http.h
@@ -124,6 +124,7 @@ void http_session_set_log_cb (http_session_t sess,
void (*cb)(http_session_t, gpg_error_t,
const char *,
const void **, size_t *));
+void http_session_set_timeout (http_session_t sess, unsigned int timeout);
gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
@@ -133,7 +134,8 @@ void http_release_parsed_uri (parsed_uri_t uri);
gpg_error_t http_raw_connect (http_t *r_hd,
const char *server, unsigned short port,
- unsigned int flags, const char *srvtag);
+ unsigned int flags, const char *srvtag,
+ unsigned int timeout);
gpg_error_t http_open (http_t *r_hd, http_req_t reqtype,
const char *url,