summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspsocket.h2
-rw-r--r--src/inspsocket.cpp24
-rw-r--r--src/modules/m_http_client.cpp4
-rw-r--r--src/modules/m_spanningtree/treesocket.h2
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
5 files changed, 23 insertions, 13 deletions
diff --git a/include/inspsocket.h b/include/inspsocket.h
index f094701c0..af93baa56 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -332,7 +332,7 @@ class CoreExport BufferedSocket : public EventHandler
* returns or linefeeds are appended to the string.
* @param data The data to send
*/
- virtual int Write(const std::string &data);
+ virtual void Write(const std::string &data);
/**
* If your socket is a listening socket, when a new
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()
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index ef3cf5c33..ef036f3f2 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -292,7 +292,9 @@ bool HTTPSocket::OnConnected()
this->status = HTTP_REQSENT;
- return this->Write(request);
+ this->Write(request);
+
+ return true;
}
bool HTTPSocket::OnDataReady()
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index e3c59e4b6..bc5bdc869 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -266,7 +266,7 @@ class TreeSocket : public BufferedSocket
/** Send one or more complete lines down the socket
*/
- int WriteLine(std::string line);
+ void WriteLine(std::string line);
/** Handle ERROR command */
bool Error(std::deque<std::string> &params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 793982ec7..152f9dec3 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -32,11 +32,11 @@
static std::map<std::string, std::string> warned; /* Server names that have had protocol violation warnings displayed for them */
-int TreeSocket::WriteLine(std::string line)
+void TreeSocket::WriteLine(std::string line)
{
Instance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
line.append("\r\n");
- return this->Write(line);
+ this->Write(line);
}