dirmngr: Allow a timeout for HTTP and other TCP connects.
authorWerner Koch <wk@gnupg.org>
Thu, 8 Jun 2017 06:23:06 +0000 (08:23 +0200)
committerWerner Koch <wk@gnupg.org>
Thu, 8 Jun 2017 07:37:36 +0000 (09:37 +0200)
commit5b9025cfa1f9b1c67ddf2f6bf87d863e780cf157
treeb0f389c2ff9dc0ea45e4bece3e41bef7a5fa397e
parent17e5afd80f247c356f03c71e8b61da424ffedabb
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 <wk@gnupg.org>
dirmngr/http.c
dirmngr/http.h
dirmngr/t-http.c