Welcome! Log In Create A New Profile

Advanced

[nginx] upstream keepalive recv MSG_PEEK check

Tolga Ceylan
September 28, 2015 03:50PM
Hi All,

A quick code base question, regarding the close (read) handler
in http_upstream_keepalive_module.c:

ngx_http_upstream_keepalive_close_handler()

has a recv() call with MSG_PEEK and if this returns NGX_EAGAIN,
then it reschedules a read on epoll for my platform (Linux x86_64).

My understanding is that this is a guard against spurious wake ups
for whatever reason from epoll wait. If an actual data is received
this is an error (since the connection is in keep alive pool and should not
receive data from upstreams) and the connection is closed in this case.
But if NGX_EAGAIN is detected, then there's no data and we continue
with adding a read event handler to epoll.

If my assumption is correct, then under what cases/circumstances do
these spurious wake ups occur? In other words, why would the read handler
be called if there's no data and recv() will return EAGAIN? In other words,
in ngx_http_upstream_keepalive_close_handler, can't we skip the recv()
check and proceed to close?

Or do these spurious wake ups occur in non-epoll platforms?

Regards,
Tolga Ceylan

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] upstream keepalive recv MSG_PEEK check

Tolga Ceylan 752 September 28, 2015 03:50PM

Re: [nginx] upstream keepalive recv MSG_PEEK check

Maxim Dounin 457 September 28, 2015 04:14PM

Re: [nginx] upstream keepalive recv MSG_PEEK check

Tolga Ceylan 334 September 28, 2015 04:30PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 245
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready