summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 17:32:55 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 17:32:55 +0000
commit53f280ed2ec0fdcac4e0e60f5d2566ae9f701a97 (patch)
tree97df3f4601e5ec5fe7a3a86ce49ff8772c62e311 /src
parent91ca2329986bf3b6611edbc88795d345a4c0353f (diff)
Check for write errors in inspsocket (this is probably causing excessive cpu use when we have a large buffer to flush but a write error has occured (which we missed))
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3518 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/socket.cpp23
-rwxr-xr-xsrc/svn-rev.sh2
2 files changed, 17 insertions, 8 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 4c03c933d..4b139c7f5 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -232,7 +232,7 @@ char* InspSocket::Read()
}
else
{
- log(DEBUG,"EOF or error on socket");
+ log(DEBUG,"EOF or error on socket: %s",strerror(errno));
return NULL;
}
}
@@ -257,7 +257,7 @@ int InspSocket::Write(std::string data)
return data.length();
}
-void InspSocket::FlushWriteBuffer()
+bool InspSocket::FlushWriteBuffer()
{
if ((this->fd > -1) && (this->state == I_CONNECTED))
{
@@ -280,8 +280,16 @@ void InspSocket::FlushWriteBuffer()
Buffer = n;
}
}
+ else if (result == -1)
+ {
+ log(DEBUG,"Write error on socket: %s",strerror(errno));
+ this->OnError(I_ERR_WRITE);
+ this->state = I_ERROR;
+ return false;
+ }
}
}
+ return true;
}
bool InspSocket::Timeout(time_t current)
@@ -299,8 +307,7 @@ bool InspSocket::Timeout(time_t current)
this->state = I_ERROR;
return true;
}
- this->FlushWriteBuffer();
- return false;
+ return this->FlushWriteBuffer();
}
bool InspSocket::Poll()
@@ -334,9 +341,11 @@ bool InspSocket::Poll()
case I_CONNECTED:
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;
+ * so there are less write calls involved.
+ * Both FlushWriteBuffer AND the return result of OnDataReady must
+ * return true for this to be ok.
+ */
+ return (n && this->FlushWriteBuffer());
break;
default:
break;
diff --git a/src/svn-rev.sh b/src/svn-rev.sh
index 7b85fd8af..5fa9d51df 100755
--- a/src/svn-rev.sh
+++ b/src/svn-rev.sh
@@ -1 +1 @@
-echo 3515
+echo 3517