Comment 4 for bug 1047593

Revision history for this message
John Bresnahan (jbresnah) wrote :

I see two ways to solve the 'get unused port' race.

1) We delay the close time of the socket as long as possible (meaning close it right before we exec the program that will use it). The calls to get the ports are here:

 https://github.com/openstack/glance/blob/master/glance/tests/functional/__init__.py#L470.

but they are not used until start is called. Further, two calls are right next to each other. On most systems the ephemeral port selection is random and thus a collision is unlikely. However we may as well eliminate that chance

2) Never close the socket. Set an ENV to the FD of that socket before forking the server off, then in the presence of that env create a socket from that FD. This solution should entirely eliminate the problem.

Any thoughts?