[PATCH] SO_REUSEPORT ?

Nils Goroll slink at schokola.de
Mon May 5 19:20:56 CEST 2014


On Solaris 11, I see intermittent varnishtest failures on arbitrary tests due to
bind failing with EADDRINUSE :

# previous test finishing up
...
22591/1:        nanosleep(0xFFFF80FFBFFFE010, 0x00000000)       = 0
22591/1:                tmout: 0.100000000 sec
22591/1:        lwp_wait(2, 0xFFFF80FFBFFFDF9C)                 = 0
22591/1:                lwpid:  2
22591/1:        close(3)                                        = 0
22591/1:        so_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP, 0, SOV_DEFAULT) = 3
22591/1:        setsockopt(3, SOL_SOCKET, SO_REUSEADDR, 0xFFFF80FFBFFFDFA8, 4,
SOV_DEFAULT) =
0
22591/1:        bind(3, 0x004B8660, 16, SOV_SOCKBSD)            Err#125 EADDRINUSE
22591/1:                AF_INET  name = 127.0.0.1  port = 45199
22591/1:        write(2, " b i n d ( )", 6)                     = 6
22591/1:        write(2, " :  ", 2)                             = 2
22578:  pollsys(0x00431F80, 1, 0xFFFF80FFBFFFF7E0, 0x00000000) = 1
22578:          fd=3  ev=POLLIN|POLLERR|POLLHUP rev=POLLIN
22578:          timeout: 59.999000000 sec
22591/1:        write(2, 0xFFFF80FFBF48A4CE, 22)                = 22
22591/1:           A d d r e s s   a l r e a d y   i n   u s e
22591/1:        write(2, "\n", 1)                               = 1
...

The problem can be avoided by not only setting SO_REUSEADDR, but also
SO_REUSEPORT in VCC_bind as shown in the attached patch.

According to http://lwn.net/Articles/542629/, this could also help performance
on huge multiple-acceptor-thread-setups:

	the SO_REUSEPORT implementation distributes connections evenly across
	all of the threads (or processes) that are blocked in accept() on the
	same port.

Nils
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-use-SO_REUSEPORT-where-availab-e.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20140505/60782ecf/attachment.bin>


More information about the varnish-dev mailing list