]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Preserve caller context across ping timeout events (#635)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Thu, 4 Jun 2020 11:23:31 +0000 (11:23 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Sat, 27 Jun 2020 14:32:05 +0000 (02:32 +1200)
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.

src/PingData.h

index c52492542116ed73653180baede58cf270e951e4..a1fc8501fd2a42b45b948356f13843cfe648bd97 100644 (file)
@@ -16,7 +16,7 @@
 class PeerSelector;
 class PeerSelectorPingMonitor;
 
-typedef std::pair<const timeval, PeerSelector *> WaitingPeerSelector;
+typedef std::pair<timeval, PeerSelector *> WaitingPeerSelector;
 /// waiting PeerSelector objects, ordered by their absolute deadlines
 typedef std::multimap<timeval, PeerSelector *, std::less<timeval>, PoolingAllocator<WaitingPeerSelector> > WaitingPeerSelectors;
 typedef WaitingPeerSelectors::iterator WaitingPeerSelectorPosition;