drbrain / net-http-persistent

Thread-safe persistent connections with Net::HTTP
http://seattlerb.rubyforge.org/net-http-persistent
339 stars 117 forks source link

Fix double-connect bug after exceeding idle_timeout #115

Closed sayap closed 4 years ago

sayap commented 4 years ago

Previously, when keep_alive_timeout <= idle_timeout, and a request arrives after exceeding idle_timeout, the following will be called:

As connect is called twice, a perfectly good connection is wasted.

Commit 1dcdf06f fixed the case when a request arrives before exceeding idle_timeout, but the above edge case remains.

Fix it by resetting the "last_communicated" value back to nil after calling Net::HTTP#finish.