KQueue: 2 or more IPv6 listen ports + HUPing causes repeated log spam

With 2 or more IPv6 listen ports enabled in nginx, if you send it about
3-4 HUPs, it will start to log spam repeatedly in
/var/log/nginx-error.log until the partition fills up with the following
error message:

I’ve tested this on FreeBSD 6.2, both 32-bit single-core and 64-bit
multi-core, as well as FreeBSD 7.1 64-bit multi-core.

To repeat:

Start up nginx with the following config file:

Send it a single HUP. Nothing should be reported in
/var/log/nginx-error.log

Send it another HUP, the following should appear in the log:

Now send it 1-2 more hups, (maybe a few more might be necessary), and
the following will appear:

And then the line from above will be repeated endlessly:

I’ve found that if you only have 1 IPv6 listen port, this doesn’t
happen. I also haven’t been able to reproduce it with IPv4 listen
ports.

– WolfSage (Matthew Horsfall)

Posted at Nginx Forum:

On Wed, Jul 07, 2010 at 11:06:35AM -0400, WolfSage wrote:

    listen       [::]:8001;

[alert] 4088#0: kevent() error on 6 filter:-1 flags:4000 (9: Bad file
[alert] 4081#0: sendmsg() failed (9: Bad file descriptor)

ports.

– WolfSage (Matthew Horsfall)

Try nginx-0.8.43+


Igor S.
http://sysoev.ru/en/

Sorry, I forgot to mention the nginx versions.

This was tested with nginx stable all the way from versions 0.6.39 to
latest stable 0.7.67.

I’d like to stay in the stable branch rather than run the development
branch.

Posted at Nginx Forum:

On Wed, Jul 07, 2010 at 11:28:29AM -0400, WolfSage wrote:

Sorry, I forgot to mention the nginx versions.

This was tested with nginx stable all the way from versions 0.6.39 to
latest stable 0.7.67.

I’d like to stay in the stable branch rather than run the development
branch.

Then try the attached patch.

BTW, I’m going to declare 0.8.x as stable branch soon. Note also that
nginx development branch is much more stable than FreeBSD’s HEAD vs
STABLE.

Hello!

On Wed, Jul 07, 2010 at 11:28:29AM -0400, WolfSage wrote:

Sorry, I forgot to mention the nginx versions.

This was tested with nginx stable all the way from versions 0.6.39 to
latest stable 0.7.67.

I’d like to stay in the stable branch rather than run the development
branch.

There are number of ipv6-related fixes in 0.8.* branch, including
the following:

(0.8.43)

*) Bugfix: nginx might close IPv6 listen socket during
   reconfiguration.

(0.8.39)

*) Bugfix: listen unix domain and IPv6 sockets did not inherit while
   online upgrade.

You are clearly hitting the bug fixed in 0.8.43. Patch is
trivial and should apply cleanly to 0.7.*:

http://mdounin.ru/hg/nginx-vendor-current/diff/c456a023113c/src/core/ngx_cycle.c

Though I would recommend to switch to 0.8.* branch instead.

Maxim D.

Thank you both, that patch works beautifully.

Posted at Nginx Forum: