summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socket.h4
-rw-r--r--src/socket.cpp23
-rwxr-xr-xsrc/svn-rev.sh2
3 files changed, 19 insertions, 10 deletions
diff --git a/include/socket.h b/include/socket.h
index 1c343f122..861d4be79 100644
--- a/include/socket.h
+++ b/include/socket.h
@@ -32,7 +32,7 @@ enum InspSocketState { I_DISCONNECTED, I_RESOLVING, I_CONNECTING, I_CONNECTED, I
/**
* Error types which a socket may exhibit
*/
-enum InspSocketError { I_ERR_TIMEOUT, I_ERR_SOCKET, I_ERR_CONNECT, I_ERR_BIND, I_ERR_RESOLVE };
+enum InspSocketError { I_ERR_TIMEOUT, I_ERR_SOCKET, I_ERR_CONNECT, I_ERR_BIND, I_ERR_RESOLVE, I_ERR_WRITE };
/**
* InspSocket is an extendable socket class which modules
@@ -143,7 +143,7 @@ private:
/** Flushes the write buffer
*/
- void FlushWriteBuffer();
+ bool FlushWriteBuffer();
void SetQueues(int nfd);
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