diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-11 00:15:42 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-11 00:15:42 +0000 |
commit | 9183ebd28c79b12ddf29b3847f59679e480af70a (patch) | |
tree | 06a0346aeea9fead8e789b6c0ff259e40df9d4b3 | |
parent | 7a7fb7167c0e96509523c378e776cf38418cd4e5 (diff) |
There is absolutely no need to cache connect timeout.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10512 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/inspsocket.h | 7 | ||||
-rw-r--r-- | src/inspsocket.cpp | 9 |
2 files changed, 6 insertions, 10 deletions
diff --git a/include/inspsocket.h b/include/inspsocket.h index f945c4f9d..13dacc90b 100644 --- a/include/inspsocket.h +++ b/include/inspsocket.h @@ -116,10 +116,6 @@ class CoreExport BufferedSocket : public EventHandler */ SocketTimeout* Timeout; - /** Timeout length - */ - unsigned long timeout_val; - /** Socket output buffer (binary safe) */ std::deque<std::string> outbuffer; @@ -351,8 +347,9 @@ class CoreExport BufferedSocket : public EventHandler /** * This method attempts to connect to a hostname. * This method is asyncronous. + * @param maxtime Number of seconds to wait, if connecting, before the connection times out and an OnTimeout() event is generated */ - virtual bool DoConnect(); + virtual bool DoConnect(unsigned long maxtime); /** Handle event from EventHandler parent class */ diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index f3917bba0..7ce98ef8a 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -42,7 +42,7 @@ BufferedSocket::BufferedSocket(InspIRCd* SI, int newfd, const char* ip) this->Instance->SE->AddFd(this); } -BufferedSocket::BufferedSocket(InspIRCd* SI, const std::string &ipaddr, int aport, unsigned long maxtime, const std::string &connectbindip) +BufferedSocket::BufferedSocket(InspIRCd* SI, const std::string &ipaddr, int aport, unsigned int maxtime, const std::string &connectbindip) { this->cbindip = connectbindip; this->fd = -1; @@ -80,8 +80,7 @@ BufferedSocket::BufferedSocket(InspIRCd* SI, const std::string &ipaddr, int apor else { strlcpy(this->IP,host,MAXBUF); - timeout_val = maxtime; - if (!this->DoConnect()) + if (!this->DoConnect(maxtime)) { this->OnError(I_ERR_CONNECT); this->Close(); @@ -192,7 +191,7 @@ bool BufferedSocket::BindAddr(const std::string &ip) return true; } -bool BufferedSocket::DoConnect() +bool BufferedSocket::DoConnect(unsigned long maxtime) { /* The [2] is required because we may write a sockaddr_in6 here, and sockaddr_in6 is larger than sockaddr, where sockaddr_in4 is not. */ sockaddr* addr = new sockaddr[2]; @@ -272,7 +271,7 @@ bool BufferedSocket::DoConnect() return false; } - this->Timeout = new SocketTimeout(this->GetFd(), this->Instance, this, timeout_val, this->Instance->Time()); + this->Timeout = new SocketTimeout(this->GetFd(), this->Instance, this, maxtime, this->Instance->Time()); this->Instance->Timers->AddTimer(this->Timeout); } |