summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-22 14:08:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-22 14:08:50 +0000
commite26c9fa8d91b9ecc6de6b5bbf490ec4391b8210b (patch)
tree74d7c72ae3ab6e4f7b96c816d83dd5ec5cb46d45
parentdefbe5dc22e8228e3a0fc0e4c7d08c0609731538 (diff)
More sensible way to flush sockets
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5517 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspsocket.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 2ddc3cf75..c7e68df6c 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -334,15 +334,21 @@ bool InspSocket::FlushWriteBuffer()
errno = 0;
if ((this->fd > -1) && (this->state == I_CONNECTED))
{
+ /* If we have multiple lines, try to send them all,
+ * not just the first one -- Brain
+ */
while (outbuffer.size() && (errno != EAGAIN))
{
+ /* Send a line */
int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length());
if (result > 0)
{
if ((unsigned int)result == outbuffer[0].length())
{
/* The whole block was written (usually a line)
- * Pop the block off the front of the queue
+ * Pop the block off the front of the queue,
+ * dont set errno, because we are clear of errors
+ * and want to try and write the next block too.
*/
outbuffer.pop_front();
}
@@ -350,6 +356,12 @@ bool InspSocket::FlushWriteBuffer()
{
std::string temp = outbuffer[0].substr(result);
outbuffer[0] = temp;
+ /* We didnt get the whole line out. arses.
+ * Try again next time, i guess. Set errno,
+ * because we shouldnt be writing any more now,
+ * until the socketengine says its safe to do so.
+ */
+ errno = EAGAIN;
}
}
else if ((result == -1) && (errno != EAGAIN))