--- mad-squid-timeout/src/comm/ConnOpener.cc 21 Jan 2013 16:48:02 -0000 1.1.1.2.6.4 +++ mad-squid-timeout/src/comm/ConnOpener.cc 23 Jan 2013 23:12:21 -0000 1.1.1.2.6.7 @@ -147,8 +147,6 @@ calls_.timeout_->cancel("Comm::ConnOpener::doneConnecting"); calls_.timeout_ = NULL; } - fd_table[temporaryFd_].timeoutHandler = NULL; - fd_table[temporaryFd_].timeout = 0; close(temporaryFd_); fd_close(temporaryFd_); temporaryFd_ = -1; @@ -192,8 +190,8 @@ typedef CommTimeoutCbParams Params; Params ¶ms = GetCommParams(calls_.timeout_); params.conn = conn_; - fd_table[temporaryFd_].timeoutHandler = calls_.timeout_; - fd_table[temporaryFd_].timeout = squid_curtime + (time_t) connectTimeout_; + + eventAdd("Comm::ConnOpener::ConnectTimeout", Comm::ConnOpener::ConnectTimeout, new Pointer(this), connectTimeout_, 0, false); connectStart_ = squid_curtime; connect(); @@ -368,3 +366,16 @@ } delete ptr; } + +void +Comm::ConnOpener::ConnectTimeout(void *data) +{ + Pointer *ptr = static_cast(data); + assert(ptr); + if (ConnOpener *cs = ptr->valid()) + // Ew. we are now outside the all AsyncJob protections. + // get back inside by scheduling another call... + ScheduleCallHere(cs->calls_.timeout_); + + delete ptr; +} --- mad-squid-timeout/src/comm/ConnOpener.h 7 Jan 2013 20:15:28 -0000 1.1.1.1 +++ mad-squid-timeout/src/comm/ConnOpener.h 23 Jan 2013 23:16:43 -0000 @@ -43,6 +43,7 @@ void doneConnecting(comm_err_t status, int xerrno); static void InProgressConnectRetry(int fd, void *data); static void DelayedConnectRetry(void *data); + static void ConnectTimeout(void *data); void connect(); void connected(); void lookupLocalAddress();