From dd168c56c95a870de3d178edda48507ca47168fe Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 30 Oct 2006 18:22:36 +0000 Subject: WARNING: This commit breaks kqueue and select -- work in progress! epoll now allows both a write and a read event on a socket at the same time. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5580 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 3be7225d4..4b7e38f3c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -639,11 +639,14 @@ void userrec::FlushWriteBuf() } if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER)) { + int old_sendq_length = sendq.length(); const char* tb = this->sendq.c_str(); int n_sent = write(this->fd,tb,this->sendq.length()); if (n_sent == -1) { - if (errno != EAGAIN) + if (errno == EAGAIN) + this->ServerInstance->SE->WantWrite(this); + else this->SetWriteError(strerror(errno)); } else @@ -654,6 +657,8 @@ void userrec::FlushWriteBuf() // update the user's stats counters this->bytes_out += n_sent; this->cmds_out++; + if (n_sent != old_sendq_length) + this->ServerInstance->SE->WantWrite(this); } } } @@ -690,6 +695,7 @@ const char* userrec::GetWriteError() void userrec::Oper(const std::string &opertype) { + this->ServerInstance->SE->WantWrite(this); try { this->modes[UM_OPERATOR] = 1; @@ -2018,7 +2024,15 @@ void userrec::HandleEvent(EventType et) /* WARNING: May delete this user! */ try { - ServerInstance->ProcessUser(this); + switch (et) + { + case EVENT_READ: + ServerInstance->ProcessUser(this); + break; + case EVENT_WRITE: + this->FlushWriteBuf(); + break; + } } catch (...) { -- cgit v1.2.3