From: brain Date: Tue, 31 Oct 2006 08:16:14 +0000 (+0000) Subject: Tidy up WaitingForWriteEvent stuff X-Git-Tag: v2.0.23~6780 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=6e3dbb2cd7edbd1bd5d3b7aba419e5d90dd0ebec;p=user%2Fhenk%2Fcode%2Finspircd.git Tidy up WaitingForWriteEvent stuff git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5594 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index d712e5c19..1e9f3eb5b 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -120,6 +120,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool void InspSocket::WantWrite() { this->Instance->SE->WantWrite(this); + this->WaitingForWriteEvent = true; } void InspSocket::SetQueues(int nfd) @@ -439,12 +440,6 @@ bool InspSocket::Poll() if (this->WaitingForWriteEvent) { - /* Switch back to read events */ - this->Instance->SE->DelFd(this); - this->WaitingForWriteEvent = false; - if (!this->Instance->SE->AddFd(this)) - return false; - /* Trigger the write event */ n = this->OnWriteReady(); } @@ -505,8 +500,24 @@ void InspSocket::HandleEvent(EventType et) } break; case EVENT_WRITE: + if (this->WaitingForWriteEvent) + { + if (!this->OnWriteReady()) + { + this->Instance->SE->DelFd(this); + this->Close(); + delete this; + return; + } + } if (this->state == I_CONNECTING) { + /* This might look wrong as if we should be actually calling + * with EVENT_WRITE, but trust me it is correct. There are some + * writeability-state things in the read code, because of how + * InspSocket used to work regarding write buffering in previous + * versions of InspIRCd. - Brain + */ this->HandleEvent(EVENT_READ); return; }