Why NGX_SOCKADDRLEN is 512?

For an IPv6, sizeof (struct sockaddr_in6) is only 28bytes, so why set
NGX_SOCKADDRLEN 512?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,179363,179363#msg-179363

On Mar 1, 2011, at 10:28 , speedfirst wrote:

For an IPv6, sizeof (struct sockaddr_in6) is only 28bytes, so why set
NGX_SOCKADDRLEN 512?

src/core/ngx_inet.h

/*

  • TODO: autoconfigure NGX_SOCKADDRLEN and NGX_SOCKADDR_STRLEN as
  •   sizeof(struct sockaddr_storage)
    
  •   sizeof(struct sockaddr_un)
    
  •   sizeof(struct sockaddr_in6)
    
  •   sizeof(struct sockaddr_in)
    

*/

[…]

#if (NGX_HAVE_UNIX_DOMAIN)
#define NGX_SOCKADDRLEN sizeof(struct sockaddr_un)
#else
#define NGX_SOCKADDRLEN 512
#endif

struct sockaddr_un size is about 110 bytes depending on platform.


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

On Mar 1, 2011, at 11:59 , speedfirst wrote:

I think this way would be better:

#if (NGX_HAVE_UNIX_DOMAIN)
#define NGX_SOCKADDRLEN sizeof(struct sockaddr_un)
#else
#define NGX_SOCKADDRLEN sizeof(struct sockaddr_storage)
#endif

sizeof(sturct sockaddr_storage) is 128 in my Linux 64bit, 512 is too
big.

The problem that struct sockaddr_storage is relatively recent thing.


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

I think this way would be better:

#if (NGX_HAVE_UNIX_DOMAIN)
#define NGX_SOCKADDRLEN sizeof(struct sockaddr_un)
#else
#define NGX_SOCKADDRLEN sizeof(struct sockaddr_storage)
#endif

sizeof(sturct sockaddr_storage) is 128 in my Linux 64bit, 512 is too
big.

anyway, this is not critical.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,179363,179379#msg-179379

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs