From 213b6491e9df23125e79506d70b2a0c7e390532c Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Thu, 17 Nov 2011 02:34:09 -0700 Subject: [PATCH] Fix Comm::Write closing() assertion when retrying a failed UDP DNS query. 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. --- src/dns_internal.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 65a10cba87..4c3f7ab314 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -767,6 +767,10 @@ idnsDoSendQueryVC(nsvc *vc) 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; -- 2.47.2