> This change is a potential performance regression for us. Our > networking code sets up multiple sockets used by multiple threads to > listen on the same udp port. For the first socket, the bind is done > before setting SO_REUSEPORT so that we can get an error and detect > that the port is currently in use by a different process, possibly a > previous incarnation of the same application. > > With this change, the servers end up with a single listener socket and > thread, which can have a large impact on performance for a busy > server. > > While we can adjust for the new behaviour going forward, this could be > an unpleasant surprise for our customers who get this update when > moving to a new kernel version or through a backport to stable > kernels, if this is targeted for stable.
Probably you can: fd1=socket() fd2=socket() bind(fd1,port=0) setsockopt(fd2,REUSEPORT,1) port = getsockname(fd1) close(fd1) bind(fd2,port) Although yeah there's a slight chance of a race (ie. 2nd bind failing, in which case close() and retry).