[PATCH] schedule connect timeouts via eventAdd

From: Rainer Weikusat <rweikusat_at_mobileactivedefense.com>
Date: Wed, 23 Jan 2013 23:28:56 +0000

Changes the ConnOpener.cc code to schedule connect timeouts via
eventAdd instead of via the fd_table/ fde timeout mechanism. This
fixes the problem that the timeout isn't defused after a successful
connect and is also intended as preparation for fixing the
connect_retries feature by detaching the connect timeout from the
'currently used' temporary file descriptor.

This patch is not yet supposed to be complete, eg, it is lacking the
kind of comment the other two 'Legacy wrapper for' methods in
ConnOpener.cc have. There's also something I'm not yet sure about:
Should the connect timeout be canceled after the connection attempt
had some definite results? The event scheduling mechanism is based on
a sorted, linked list of events so insertion and deletion of an event
are O(n). Inserting an event (connection start) and almost immediately
removing it again in most cases (connection succeeded) will be twice
as expensive as just leaving it scheduled, counting on the invoked
method becoming a no-op after the associated ConnOpener was
destroyed. The downside of this approach is that this means adding
future connect timeouts will become proportionally more expensive as
more and more connections are being established until the first of
them start to 'wither away' after a minute. I'm probably going to add
some instrumentation code to events.cc to get some numbers regarding
the cost of either approach.

NB: The patch was generated on top of the 'move the timeout' patch but
also applies (to the r12452 3.3.0.3 intermediate release') without it.

Received on Wed Jan 23 2013 - 23:29:14 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 24 2013 - 12:00:08 MST