Skip to content

Commit

Permalink
Win32: Remove timeout_ms member from apr_socket_t.
Browse files Browse the repository at this point in the history
* include/arch/win32/apr_arch_networkio.h
  (apr_socket_t): Remove timeout_ms.

* network_io/win32/sendrecv.c
  (apr_socket_sendfile): Use apr_wait_for_single_object() to wait for
   sock->timeout.

* network_io/win32/sockopt.c
  (apr_socket_timeout_set): Use local variable instead of sock->timeout_ms.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1920120 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Ivan Zhakov committed Aug 21, 2024
1 parent e8e615d commit cf6c66b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion include/arch/win32/apr_arch_networkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct apr_socket_t {
int protocol;
apr_sockaddr_t *local_addr;
apr_sockaddr_t *remote_addr;
int timeout_ms; /* MUST MATCH if timeout > 0 */
apr_interval_time_t timeout;
apr_int32_t disconnected;
int local_port_unknown;
Expand Down
5 changes: 2 additions & 3 deletions network_io/win32/sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,8 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock,
if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) ||
(status == APR_FROM_OS_ERROR(WSA_IO_PENDING)))
{
rv = WaitForSingleObject(sock->overlapped->hEvent,
(DWORD)(sock->timeout >= 0
? sock->timeout_ms : INFINITE));
rv = apr_wait_for_single_object(sock->overlapped->hEvent, sock->timeout);

if (rv == WAIT_OBJECT_0) {
status = APR_SUCCESS;
if (!WSAGetOverlappedResult(sock->socketdes,
Expand Down
10 changes: 5 additions & 5 deletions network_io/win32/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interva
if (sock->timeout != t)
{
/* Win32 timeouts are in msec, represented as int */
sock->timeout_ms = (int)apr_time_as_msec(t);
int timeout_ms = (int)apr_time_as_msec(t);
setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO,
(char *) &sock->timeout_ms,
sizeof(sock->timeout_ms));
(char *) &timeout_ms,
sizeof(timeout_ms));
setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO,
(char *) &sock->timeout_ms,
sizeof(sock->timeout_ms));
(char *) &timeout_ms,
sizeof(timeout_ms));
}
}
else if (t < 0) {
Expand Down

0 comments on commit cf6c66b

Please sign in to comment.