Following scenario will cause the hang
imap = Net::IMAP.new('mail.example.com')
imap.disconnect
This is because disconnect method waits on graceful shut down of the receiver thread which will never happen. The most
likely scenario is that the IMAP server will send an untagged BYE due to idle timeout. That will trigger ByeResponseError
exception, a rather undesirable side effect.
The patch changes how disconnect method is implemented. Receiver thread will killed after if it doesn't shut down gracefully
after a short time interval. |