diff options
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/os2/sockopt.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/network_io/os2/sockopt.c b/network_io/os2/sockopt.c index 2ada4fc47..0cce8d78e 100644 --- a/network_io/os2/sockopt.c +++ b/network_io/os2/sockopt.c @@ -32,8 +32,22 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t) { + apr_status_t rv = APR_SUCCESS; + + /* If our new timeout is non-negative and our old timeout was + * negative, then we need to ensure that we are non-blocking. + * Conversely, if our new timeout is negative and we had + * non-negative timeout, we must make sure our socket is blocking. + */ + if (t == 0 && sock->timeout != 0) { + rv = apr_socket_opt_set(sock, APR_SO_NONBLOCK, 1); + } + else if (t != 0 && sock->timeout == 0) { + rv = apr_socket_opt_set(sock, APR_SO_NONBLOCK, 0); + } + sock->timeout = t; - return APR_SUCCESS; + return rv; } |