On Sat, 14 Sep 2019 at 16:44, Ivan Zhakov <i...@visualsvn.com> wrote:

> Hi!
>
> The apr_socket_sendfile() has Windows specific flag
> APR_SENDFILE_DISCONNECT_SOCKET. When this flag specified
> instructs Winsock to disconnect socket and prepare it for
> reuse after file send.
>
> There are several problems with this flag:
> 1. The TCP socket may be subject to the TCP TIME_WAIT state.
>    That means apr_sock_sendfile() could occupy worker thread
>    for significant time (30 seconds)
>
> 2. When flag specified socket descriptor is removed from
>    apr_socket_t and will not be cleaned up. The caller
>    expected to maintain original socket descriptor and release
>    if APR_SENDFILE_DISCONNECT_SOCKET is used.
>
> As far I see Apache HTTP Server doesn't use APR_SENDFILE_DISCONNECT_SOCKET
> flag.
>
> As far I understand proper way to reuse sockets is to use DisconnectEx()
> [1].
> Application should use DisconnectEx() in overlapped I/O mode and wait
> for it completion using completion port or thread pool. When overlapped I/O
> is done the socket could be added to reuse list and later used for
> AcceptEx() or
> ConnectEx().
>
> So I propose to remove APR_SENDFILE_DISCONNECT_SOCKET flag in APR 2.0 for
> the
> reasons above. Patch is attached.
>
> Any objections?
>
> [1]
> https://docs.microsoft.com/en-gb/windows/win32/api/mswsock/nc-mswsock-lpfn_disconnectex
>
> Committed tweaked patch in r1867226.

-- 
Ivan Zhakov

Reply via email to