Welcome! Log In Create A New Profile

Advanced

Re: [nginx] upstream keepalive recv MSG_PEEK check

Maxim Dounin
September 28, 2015 04:14PM
Hello!

On Mon, Sep 28, 2015 at 12:49:33PM -0700, Tolga Ceylan wrote:

> 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?

Detailed explanation and a test case can be found here:

http://mdounin.ru/hg/ngx_http_upstream_keepalive/rev/9a4ee6fe1c6d

--
Maxim Dounin
http://nginx.org/

_______________________________________________
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 761 September 28, 2015 03:50PM

Re: [nginx] upstream keepalive recv MSG_PEEK check

Maxim Dounin 460 September 28, 2015 04:14PM

Re: [nginx] upstream keepalive recv MSG_PEEK check

Tolga Ceylan 338 September 28, 2015 04:30PM



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

Online Users

Guests: 156
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