X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=2fb811508b7608810b8d835454e055fbca873acd;hb=813bc55a8496875cef52e6da42d608e4d2fa35da;hp=41f40dc2bef696380d690db94b1817e9b1e58c48;hpb=da074814501f23680b579feb1ad649c86e8a1348;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 41f40dc2b..2fb811508 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -363,7 +363,8 @@ void BufferedSocket::Close() { try { - Instance->Config->GetIOHook(this)->OnRawSocketClose(this->fd); + if (this->state != I_LISTENING) + Instance->Config->GetIOHook(this)->OnRawSocketClose(this->fd); } catch (CoreException& modexcept) { @@ -434,21 +435,25 @@ const char* BufferedSocket::Read() } } -void BufferedSocket::MarkAsClosed() -{ -} - -// There are two possible outcomes to this function. -// It will either write all of the data, or an undefined amount. -// If an undefined amount is written the connection has failed -// and should be aborted. -int BufferedSocket::Write(const std::string &data) +/* + * This function formerly tried to flush write buffer each call. + * While admirable in attempting to get the data out to wherever + * it is going, on a full socket, it's just going to syscall write() and + * EAGAIN constantly, instead of waiting in the SE to know if it can write + * which will chew a bit of CPU. + * + * So, now this function returns void (take note) and just adds to the sendq. + * + * It'll get written at a determinate point when the socketengine tells us it can write. + * -- w00t (april 1, 2008) + */ +void BufferedSocket::Write(const std::string &data) { - /* Try and append the data to the back of the queue, and send it on its way - */ + /* Append the data to the back of the queue ready for writing */ outbuffer.push_back(data); + + /* Mark ourselves as wanting write */ this->Instance->SE->WantWrite(this); - return (!this->FlushWriteBuffer()); } bool BufferedSocket::FlushWriteBuffer()