Fix file descriptor leak in resolv.rb #5074
There's an edge case in resolv.rb that can lead to file descriptor leaks on a highly saturated system (logstash in our case).
(the cliff at the end is from a restart of logstash)
We're using the logstash-filter-dns plugin which uses timeout.
When a timeout fires while waiting for a random port, the new object is never returned to the caller. Instead
The text was updated successfully, but these errors were encountered:
While d1a760e fixed handling of compressed IPv6 addresses, it also broke the "freeing" part of it. Currently every DNS request leaks single request id: ``` require 'resolv' Resolv::DNS::RequestID.values.map(&:length) Resolv::DNS.new.getaddress('example.com') Resolv::DNS::RequestID.values.map(&:length) ``` Given the fact that request ids are chosen from `0x0000..0xffff` range - the app can issue 65535 requests and then will be blocked forever trying to allocate another one. This commit makes request id caching work by using same data for allocation and freeing.