The SO_REUSEPORT socket option
The SO_REUSEPORT socket option
Posted Jun 8, 2014 5:40 UTC (Sun) by wahern (subscriber, #37304)In reply to: The SO_REUSEPORT socket option by andresfreund
Parent article: The SO_REUSEPORT socket option
The current implementation doesn't actually support that. That's because each socket has its own queue, and when the 3-way handshake completes a connection is assigned to exactly one of those queues. That creates a race condition between accept(2) and close(2).
So, no, this doesn't support seamless server restarts.
Ironically it's the BSD semantics which support seamless server restarts. In my tests OS X's behavior (which I presume is identical to FreeBSD and other BSDs) is that the last socket to bind is the only one to receive new connections. That allows the old server to drain its queue and retire without worrying about any dropped connections.