I've been using the libpq asynchronous functions to hook up database
calls into my event loop, and I've noticed a problem and was hoping
someone might know the solution.
The problem is that I have to unregister the file descriptor from the
event loop whenever the postgres connection fails, but often by the
time I notice it has failed in the code, it has already closed its
socket and so I can't guarantee that if I close the previously opened
socket that it hasn't already been opened up by someone else.