diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-31 08:16:14 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-31 08:16:14 +0000 |
commit | 6e3dbb2cd7edbd1bd5d3b7aba419e5d90dd0ebec (patch) | |
tree | 3c563909659b7483d3deb18a80464cdcecc40736 | |
parent | 83a688082ed4912000e6e3a9966060099e3e0c06 (diff) |
Tidy up WaitingForWriteEvent stuff
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5594 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/inspsocket.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
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; } |