Fix a race in socket code
in socket.c we have:
if (SOCK_DEAD(sock)) { /* Sock is being closed, bail */
goto unlock_fd;
}
isc_refcount_increment(&sock->references);
However, if between SOCK_DEAD and isc_refcount_increment something will close the socket (decreasing refcount to 0) we'll have an ugly race.
The proper way to fix it should be to hold a reference for socket in thread->fds[fd].