Skip to content

Commit 53ca9c9

Browse files
committed
Fix confusion of received response message
This is a follow up for commit 33fb966 ("Remove sender/message_id pair after response received in resolv", 2020-09-11). As the @senders instance variable is also used for tracking transaction ID allocation, simply removing an entry without releasing the ID would eventually deplete the ID space and cause Resolv::DNS.allocate_request_id to hang. It seems the intention of the code was to check that the received DNS message is actually the response for the question made within the method earlier. Let's have it actually do so. [Bug #12838] https://bugs.ruby-lang.org/issues/12838 [Bug #17748] https://bugs.ruby-lang.org/issues/17748
1 parent 0a0d0ce commit 53ca9c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/resolv.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -696,17 +696,17 @@ def request(sender, tout)
696696
rescue DecodeError
697697
next # broken DNS message ignored
698698
end
699-
if s = sender_for(from, msg)
699+
if sender == sender_for(from, msg)
700700
break
701701
else
702702
# unexpected DNS message ignored
703703
end
704704
end
705-
return msg, s.data
705+
return msg, sender.data
706706
end
707707

708708
def sender_for(addr, msg)
709-
@senders.delete([addr,msg.id])
709+
@senders[[addr,msg.id]]
710710
end
711711

712712
def close

0 commit comments

Comments
 (0)