Fix the latest round of "Connection terminated unexpectedly" errors
The fix introduced in
ef7fc058 for bug 578990 caught most cases where
we'd write a request to an already-closed connection, but not all.
Unfortunately, at some point the code path for recovering from that
case got broken, so when it did happen, we'd always end up returning
the error to the app rather than retrying the request. This is now
fixed again.
The specific recent cause of the problem was that the
multiple-pending-connections fix (
baa316ac/bug 594768) results in us
sometimes opening more connections than we need, and so some of those
connections become idle without ever having had a message sent across
them. Servers tend to have different timeouts/behaviors here than with
idle persistent connections, so we should time them out more
aggressively. So now we close a connection after 3 seconds if it
hasn't been used yet.