From 7d5e82ead27f83364e1f018bf9626ac125d6642b Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 7 Feb 2006 18:45:00 +0000 Subject: Uses less write() calls git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3129 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index 15a076273..550783aed 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -236,7 +236,6 @@ char* InspSocket::Read() int InspSocket::Write(std::string data) { this->Buffer.append(data); - this->FlushWriteBuffer(); return data.length(); } @@ -277,14 +276,14 @@ bool InspSocket::Timeout(time_t current) this->state = I_ERROR; return true; } - if (this->Buffer.length()) - this->FlushWriteBuffer(); + this->FlushWriteBuffer(); return false; } bool InspSocket::Poll() { int incoming = -1; + bool n = true; switch (this->state) { @@ -310,15 +309,15 @@ bool InspSocket::Poll() return true; break; case I_CONNECTED: - return this->OnDataReady(); + n = this->OnDataReady(); + /* Flush any pending, but not till after theyre done with the event + * so there are less write calls involved. */ + this->FlushWriteBuffer(); + return n; break; default: break; } - - if (this->Buffer.length()) - this->FlushWriteBuffer(); - return true; } -- cgit v1.2.3