diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-12 20:48:30 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-13 16:42:04 +0100 |
| commit | fad90428970e332153027773b517a1606c0efa1f (patch) | |
| tree | 499ad297bc61c02e7151aa76e0cf205142fa150d /include/git2/common.h | |
| parent | 933b04c219b49d0f9cd779d024bfa39d806839ac (diff) | |
| download | libgit2-fad90428970e332153027773b517a1606c0efa1f.tar.gz | |
streams: sockets are non-blocking and can timeout
Make socket I/O non-blocking and add optional timeouts.
Users may now set `GIT_OPT_SET_SERVER_CONNECT_TIMEOUT` to set a shorter
connection timeout. (The connect timeout cannot be longer than the
operating system default.) Users may also now configure the socket read
and write timeouts with `GIT_OPT_SET_SERVER_TIMEOUT`.
By default, connects still timeout based on the operating system
defaults (typically 75 seconds) and socket read and writes block.
Add a test against our custom testing git server that ensures that we
can timeout reads against a slow server.
Diffstat (limited to 'include/git2/common.h')
| -rw-r--r-- | include/git2/common.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index f968deb23..ab6bc1333 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -224,7 +224,11 @@ typedef enum { GIT_OPT_GET_OWNER_VALIDATION, GIT_OPT_SET_OWNER_VALIDATION, GIT_OPT_GET_HOMEDIR, - GIT_OPT_SET_HOMEDIR + GIT_OPT_SET_HOMEDIR, + GIT_OPT_SET_SERVER_CONNECT_TIMEOUT, + GIT_OPT_GET_SERVER_CONNECT_TIMEOUT, + GIT_OPT_SET_SERVER_TIMEOUT, + GIT_OPT_GET_SERVER_TIMEOUT } git_libgit2_opt_t; /** @@ -480,6 +484,27 @@ typedef enum { * > * > - `path` directory of home directory. * + * opts(GIT_OPT_GET_SERVER_CONNECT_TIMEOUT, int *timeout) + * > Gets the timeout (in milliseconds) to attempt connections to + * > a remote server. + * + * opts(GIT_OPT_SET_SERVER_CONNECT_TIMEOUT, int timeout) + * > Sets the timeout (in milliseconds) to attempt connections to + * > a remote server. This is supported only for HTTP(S) connections + * > and is not supported by SSH. Set to 0 to use the system default. + * > Note that this may not be able to be configured longer than the + * > system default, typically 75 seconds. + * + * opts(GIT_OPT_GET_SERVER_TIMEOUT, int *timeout) + * > Gets the timeout (in milliseconds) for reading from and writing + * > to a remote server. + * + * opts(GIT_OPT_SET_SERVER_TIMEOUT, int timeout) + * > Sets the timeout (in milliseconds) for reading from and writing + * > to a remote server. This is supported only for HTTP(S) + * > connections and is not supported by SSH. Set to 0 to use the + * > system default. + * * @param option Option key * @param ... value to set the option * @return 0 on success, <0 on failure |
