File descriptor leak in resolv.rb
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 the application)
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
requester is set to nil. There's no handle to any sockets that were created in the initializer, so they can't be closed, and one ore more file descriptors is leaked.
(This if my first patch submission, let me know what I can fix or do better.)
Updated by nobu (Nobuyoshi Nakada) almost 5 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62671.
resolv.rb: close socket
lib/resolv.rb (UnconnectedUDP#lazy_initialize): store new
sockets before binding, so the sockets get closed when the
requester is closing.
lib/resolv.rb (ConnectedUDP#lazy_initialize): ditto.
lib/resolv.rb (UnconnectedUDP#close): synchronize to get rid of
lib/resolv.rb (ConnectedUDP#close): ditto.
From: quixoten (Devin Christensen) email@example.com