Preserve caller context across ping timeout events (#635)
PeerSelector was losing its transaction context while handling an
event-driven timeout. Also, the old code generating HandlePingTimeout
event was problematic for two reasons:
* it used raw 'this' for cbdata-protected child class. Sooner or later,
code like this leads to "real" bugs similar to those fixed in
ce9bb79,
38a9f55 /
9e64d84, and
4299f87.
* It (mis)used event API for the transaction-specific purpose.
We created a new "ping timeout service" that keeps at most one
transaction-agnostic event.h timeout at any given time while maintaining
an internal list of transactions awaiting a ping response. Similar
architecture was used for HappyConnOpener helper services.
We rejected the alternative idea of enhancing event API to support
asynchronous calls because event.cc internals were never meant to handle
thousands of concurrently pending transaction-related timeouts on busy
proxies. While it would be possible to enhance those internals as well,
timeout services offer an even better performance, are much easier to
enhance to support timeout reconfigurations, and offer better "Squid
state" debugging.