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

**URL:** <https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218>\
**Category:** NGINX\
**Created:** [July 7, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218 "2010-07-07T17:07:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/1 "2010-07-07T17:07:33Z")

</div>

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:

> [@](#):
>
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)

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:

> [@](#):
>
> worker\_processes 1;
> 
> events {  
> worker\_connections 1024;  
> }
> 
> http {  
> server {  
> listen [::]:8001;  
> listen [::]:8002;  
> }  
> }

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:

> [@](#):
>
> [alert] 4088#0: kevent() error on 6 filter:-1 flags:4000 (9: Bad file  
> descriptor)  
> [emerg] 4085#0: close() socket [::]:8002 failed (9: Bad file  
> descriptor)  
> [alert] 4088#0: kevent() error on 6 filter:-1 flags:4000 (9: Bad file  
> descriptor)

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

> [@](#):
>
> [alert] 4081#0: sendmsg() failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [emerg] 4101#0: close() socket [::]:8002 failed (9: Bad file  
> descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4081#0: close() channel failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4081#0: sendmsg() failed (9: Bad file descriptor)

And then the line from above will be repeated endlessly:

> [@](#):
>
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> [alert] 4104#0: kevent() failed (9: Bad file descriptor)  
> …

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:

> **[KQueue: 2 or more IPv6 listen ports + HUPing causes repeated log spam](https://forum.nginx.org/read.php?2,106308,106308#msg-106308)**
>
> 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: \[quote\]\[alert\] 4104#0: kevent() failed...

---

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 5:12pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/2 "2010-07-07T17:12:49Z")

</div>

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.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 5:29pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/3 "2010-07-07T17:29:13Z")

</div>

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:

> **[Re: KQueue: 2 or more IPv6 listen ports + HUPing causes repeated log spam](https://forum.nginx.org/read.php?2,106308,106312#msg-106312)**
>
> 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: \[quote\]\[alert\] 4104#0: kevent() failed...

---

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/4 "2010-07-07T17:41:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 5:58pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/5 "2010-07-07T17:58:30Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![WolfSage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/58956e/32.png) [@WolfSage](https://www.ruby-forum.com/u/WolfSage)\
**Post date:** [July 7, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/kqueue-2-or-more-ipv6-listen-ports-huping-causes-repeated-log-spam/191218/6 "2010-07-07T18:10:14Z")

</div>

Thank you both, that patch works beautifully.

Posted at Nginx Forum:

> **[Re: KQueue: 2 or more IPv6 listen ports + HUPing causes repeated log spam](https://forum.nginx.org/read.php?2,106308,106326#msg-106326)**
>
> 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: \[quote\]\[alert\] 4104#0: kevent() failed...
