apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: windows nagle settings
Date Mon, 14 Apr 2003 23:44:38 GMT
Allan Edwards wrote:

> MS doc for accept states that the accept socket "..has the same properties
> as.." the listen socket. An AcceptEx socket will inherit the properties of
> the listen socket when setsockopt(SO_UPATE_CONTEXT) is called (which we 
> do).
> 
>> Setting them to 1 when some Windows socket layers don't work that way 
>> it will break the application.
> 
> 
> FIOBIO and TCP_NODELAY are part of the Winsock2 API so I see no reason
> to exclude them.

If all this means that "WILL" goes in both blanks in the statements I 
posted, then by all means define both of those symbols to 1 in the 
header file.  Unfortunately, I am not able to translate what you are 
saying into "WILL" or "WILL NOT" :)

> [snip]
> 
>> As far as the ap_sock_disable_nagle() calls...  That doesn't seem to 
>> be implemented in the most clear manner.  The calls Apache makes are 
>> dependent on APR_TCP_NODELAY_INHERITED and 
>> AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK.  I would think that it should work 
>> this way:
> 
> 
> Agreed the original code is somewhat confusing.
> 
>> a) when setting up listening socket, unconditionally call 
>> ap_sock_disable_nagle()
>> b) when setting up a newly-connected socket, unconditionally call 
>> ap_sock_disable_nagle()
>>
>> Very little extra overhead will be incurred since the APR setting of 
>> APR_TCP_NODELAY_INHERITED will determine whether or not a syscall is 
>> used when ap_sock_disable_nagle() calls 
>> apr_socket_option_set(APR_TCP_NODELAY) on the newly-connected socket.
> 
> 
> mmm, that's not what happens on Windows. The Accept apr_socket_t doesn't
> pick up APR_TCP_NODELAY from the Listen socket and we incur the extra
> syscall for every newly connected socket. At the moment I'm not sure
> how hard it would be to fix that.

it happens in apr_socket_accept() if the two preprocessor symbols are 
defined properly:

#if APR_TCP_NODELAY_INHERITED
     if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1) {
         apr_set_option(&(*new)->netmask, APR_TCP_NODELAY, 1);
     }
#endif /* TCP_NODELAY_INHERITED */
#if APR_O_NONBLOCK_INHERITED
     if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) == 1) {
         apr_set_option(&(*new)->netmask, APR_SO_NONBLOCK, 1);
     }
#endif /* APR_O_NONBLOCK_INHERITED */

Oops, I guess you mean that it doesn't happen *in Apache* on Windows 
because the WinNT MPM doesn't call apr_socket_accept() but instead calls 
AcceptEx() directly.  And the WinNT MPM has no way to tell APR to copy 
the inherited flags from the listening socket to the connected socket.

Finally I see that the patch you posted originally is all you need to 
deal with the fact that the WinNT MPM doesn't call apr_socket_accept().

(I guess I was supposed to guess all of these details when you first 
posted the patch and not trouble anybody with my questions, but alas I 
had no crystal ball and there was no explanation to make up for it :) )


Mime
View raw message