Problem upgrading on the fly when ipv6 is used

Hi!

I’ve always upgraded nginx on the fly following this guide:
CommandLine | NGINX without problems.
I recently added IPv6 support to nginx and now, when I need to upgrade
it, it doesn’t start the new instance when I send the USR2 signal to the
master process, giving the following erros:

2010/05/29 09:05:52 [notice] 21060#0: using inherited sockets from 
"14;15;"
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 
failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already 
in use)
2010/05/29 09:05:52 [emerg] 21060#0: still could not bind()
[emerg]: still could not bind()

I’m using nginx 0.8.37 and I was trying to upgrade to 0.8.38.
Here’s an example of my nginx configuration regarding IPv6 (all the
other vhost have the same one):

    server { # php/fastcgi
        listen [2001:41D0:2:8673::1];
        listen 80;
        server_name  img.italiansubs.net;
        access_log   logs/img.access.log  main;
        root         /var/www/img.italiansubs.net/public_html;


        location / {
            index    index.html index.htm index.php index.xml;
        }

        location /news2/data/ {
            expires 35d;
        }

        location ~ \.php$ {
            fastcgi_pass   unix:/tmp/php-fpm.sock;
#             fastcgi_pass   127.0.0.1:9000;
        }
    }

If I manually restart nginx via init script it works, but of course all
the open connections are dropped, which is something I would like to
avoid.

Thanks a lot,
Andrea

Posted at Nginx Forum:

Hello!

On Sat, May 29, 2010 at 03:23:54AM -0400, Usu wrote:

I’ve always upgraded nginx on the fly following this guide:
CommandLine | NGINX without problems.
I recently added IPv6 support to nginx and now, when I need to
upgrade it, it doesn’t start the new instance when I send the
USR2 signal to the master process, giving the following erros:

[code]
2010/05/29 09:05:52 [notice] 21060#0: using inherited sockets from “14;15;”
2010/05/29 09:05:52 [emerg] 21060#0: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already in use)
[emerg]: bind() to [2001:41d0:2:8673::1]:80 failed (98: Address already in use)

[…]

Attached patch should resolve this issue.

Maxim D.

Hello!

On Mon, May 31, 2010 at 03:57:28AM -0400, Usu wrote:

Hello,

thanks for the help, I tried patching the 0.8.38 release but it’s giving me an error:

root@localhost:/usr/src/nginx-0.8.38# patch -p1 < ipv6.diff
patching file src/core/ngx_connection.c
Hunk #1 FAILED at 96.
1 out of 1 hunk FAILED – saving rejects to file src/core/ngx_connection.c.rej

And here’s the file generated:

[…]

Am I doing something wrong?

It’s mailing list ↔ forum gateway which tried to interpret
bbcodes and mungled patch. You may obtain correct one from here:

http://nginx.org/pipermail/nginx/2010-May/020621.html

Maxim D.

Ok, it works like a charm thank you!
Will it be fixed in the next release of nginx?

Posted at Nginx Forum:

Hello!

On Mon, May 31, 2010 at 07:53:51AM -0400, Usu wrote:

Ok, it works like a charm thank you!
Will it be fixed in the next release of nginx?

It’s up to Igor, but most likely it will be fixed.

Maxim D.

On Mon, May 31, 2010 at 05:13:15PM +0400, Maxim D. wrote:

Hello!

On Mon, May 31, 2010 at 07:53:51AM -0400, Usu wrote:

Ok, it works like a charm thank you!
Will it be fixed in the next release of nginx?

It’s up to Igor, but most likely it will be fixed.

Yes, I will include it in 0.8.39, thank you.


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

Hello,

thanks for the help, I tried patching the 0.8.38 release but it’s giving
me an error:

root@localhost:/usr/src/nginx-0.8.38# patch -p1 < ipv6.diff
patching file src/core/ngx_connection.c
Hunk #1 FAILED at 96.
1 out of 1 hunk FAILED – saving rejects to file
src/core/ngx_connection.c.rej

And here’s the file generated:

*************** ngx_set_inherited_sockets(ngx_cycle_t *c
*** 96,109 ****
      ls = cycle->listening.elts;
      for (i = 0; i < cycle->listening.nelts; i++) {

-         /* AF_INET only */
-
-         ls.sockaddr = ngx_palloc(cycle->pool, sizeof(struct 
sockaddr_in));
          if (ls.sockaddr == NULL) {
              return NGX_ERROR;
          }

-         ls.socklen = sizeof(struct sockaddr_in);
          if (getsockname(ls.fd, ls.sockaddr, &ls.socklen) == -1) {
              ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
                            "getsockname() of the inherited "
--- 96,107 ----
      ls = cycle->listening.elts;
      for (i = 0; i < cycle->listening.nelts; i++) {

+         ls.sockaddr = ngx_palloc(cycle->pool, NGX_SOCKADDRLEN);
          if (ls.sockaddr == NULL) {
              return NGX_ERROR;
          }

+         ls.socklen = NGX_SOCKADDRLEN;
          if (getsockname(ls.fd, ls.sockaddr, &ls.socklen) == -1) {
              ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
                            "getsockname() of the inherited "

Am I doing something wrong?

Thanks,
Andrea

Posted at Nginx Forum: