diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-01 18:56:31 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-01 18:56:31 +0000 |
commit | 86c2b7abf7f8627c9f765b12ec334d1541dcfb61 (patch) | |
tree | af2950b70648cbed2078c42eb2323b0a3a9e1743 /src/inspsocket.cpp | |
parent | 6953371f7133223ea85e815530320715bae43cc6 (diff) |
Remove call to FlushWriteBuffer from BufferedSocket::Write(), this means we don't try write() pointlessly when we may very well not (chewing CPU), and instead waits for the socketengine to tell us we can write. Tested, works fine. (nothing used this return value anyway)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9247 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspsocket.cpp')
-rw-r--r-- | src/inspsocket.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index c6fcf8fd6..95d119800 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -434,17 +434,25 @@ const char* BufferedSocket::Read() } } -// 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() |