summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-26 23:01:34 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-26 23:01:34 +0000
commit5c731e5c99cc4a60d3918260acb8d83a35077e3e (patch)
tree0e2a78428395715ad58c6547b0467f6b1ade82a0
parent6a320c380e50fe9b8af1a976e5cb54ad2398db9e (diff)
Tweaks for valgrind (again)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3356 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/socket.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 1db915e4a..e240d1208 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -63,6 +63,7 @@ InspSocket::InspSocket(std::string ahost, int aport, bool listening, unsigned lo
{
this->fd = -1;
this->host = ahost;
+ this->Buffer = "";
if (listening) {
if ((this->fd = OpenTCPSocket()) == ERROR)
{
@@ -258,23 +259,26 @@ int InspSocket::Write(std::string data)
void InspSocket::FlushWriteBuffer()
{
- int result = 0;
- const char* n = this->Buffer.c_str();
- int v = this->Buffer.length();
- if (v > 0)
+ if ((this->fd > -1) && (this->state == I_CONNECTED))
{
- result = send(this->fd,n,v,0);
- if (result > 0)
+ int result = 0;
+ const char* n = Buffer.c_str();
+ int v = Buffer.length();
+ if (v > 0)
{
- if (result == v)
+ result = write(this->fd,n,v);
+ if (result > 0)
{
- this->Buffer = "";
- }
- else
- {
- /* If we wrote some, advance the buffer forwards */
- n += result;
- this->Buffer = n;
+ if (result == v)
+ {
+ Buffer = "";
+ }
+ else
+ {
+ /* If we wrote some, advance the buffer forwards */
+ n += result;
+ Buffer = n;
+ }
}
}
}