Fix for bad file descr() after closing connection