When we receive a UDP DNS response with a truncation (TC) bit set, we retry
using TCP. Since the retry trigger has nothing to do with the TCP connection,
it is possible that the TCP connection is being closed when we are about to
write to it: A call to our connection close callback has been scheduled but
has not fired yet. We must check for and avoid such race conditions.
if (vc->queue->contentSize() == 0)
return;
+ // if retrying after a TC UDP response, our close handler cb may be pending
+ if (fd_table[vc->conn->fd].closing())
+ return;
+
MemBuf *mb = vc->queue;
vc->queue = new MemBuf;