From 479fc1ce3fa909dd326263cd2639838a0a70bd08 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 24 Dec 2010 20:02:25 -0500 Subject: Handle not being able to completely flush our write buffer correctly --- src/sockets.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sockets.cpp b/src/sockets.cpp index 9e32f85eb..54fdfc03b 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -435,16 +435,14 @@ bool BufferedSocket::ProcessRead() */ bool BufferedSocket::ProcessWrite() { - if (WriteBuffer.empty()) - { + if (this->WriteBuffer.empty()) return true; - } - if (this->IO->Send(this, WriteBuffer) == -1) - { + int count = this->IO->Send(this, this->WriteBuffer); + if (count == -1) return false; - } - WriteBuffer.clear(); - SocketEngine->ClearWritable(this); + this->WriteBuffer = this->WriteBuffer.substr(count); + if (this->WriteBuffer.empty()) + SocketEngine->ClearWritable(this); return true; } -- cgit