[remote-processor] Add context information on failure
BZ: 190038
Remote processor was not displaying information in case of network
read/write error.
Add some error messages to ease debug.
Change-Id: I465062e8cf77f94b3d4d4d0c71338c4630aac276
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
diff --git a/remote-processor/Socket.cpp b/remote-processor/Socket.cpp
index 07e6b60..b36d32f 100644
--- a/remote-processor/Socket.cpp
+++ b/remote-processor/Socket.cpp
@@ -113,6 +113,8 @@
switch (iAccessedSize) {
case 0:
// recv return value is 0 when the peer has performed an orderly shutdown.
+ _disconnected = true;
+ errno = ECONNRESET; // Warn the client that the client disconnected.
return false;
case -1:
@@ -141,6 +143,10 @@
int32_t iAccessedSize = ::send(_iSockFd, &pucData[uiOffset], uiSize, MSG_NOSIGNAL);
if (iAccessedSize == -1) {
+ if (errno == ECONNRESET) {
+ // Peer has disconnected
+ _disconnected = true;
+ }
// errno == EINTR => The send system call was interrupted, try again
if (errno != EINTR) {
return false;
@@ -158,3 +164,7 @@
{
return _iSockFd;
}
+
+bool CSocket::hasPeerDisconnected() {
+ return _disconnected;
+}