aboutsummaryrefslogtreecommitdiffstats
path: root/remote-processor
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2014-04-24 15:14:53 +0200
committerMattijs Korpershoek <mattijsx.korpershoek@intel.com>2014-06-25 10:52:27 +0200
commitf976f3749c6639915a646a88049fe523e3d5f051 (patch)
treea6e218cfcc730798cdc58c5308b52a844bbefac5 /remote-processor
parent3dd67addc686e490ac4b710250d1d5fca4ca0729 (diff)
downloadexternal_parameter-framework-f976f3749c6639915a646a88049fe523e3d5f051.zip
external_parameter-framework-f976f3749c6639915a646a88049fe523e3d5f051.tar.gz
external_parameter-framework-f976f3749c6639915a646a88049fe523e3d5f051.tar.bz2
Remote-processor continue on EINTR
BZ: 190038 EINTR is a normal error and should not fail recv or send. Continue if those errors are received. Change-Id: I66416153eb432b8f7daf97119c7c59c87e88da08 Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com> Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Diffstat (limited to 'remote-processor')
-rw-r--r--remote-processor/Socket.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/remote-processor/Socket.cpp b/remote-processor/Socket.cpp
index 3530453..07e6b60 100644
--- a/remote-processor/Socket.cpp
+++ b/remote-processor/Socket.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2011-2014, Intel Corporation
* All rights reserved.
*
@@ -34,6 +34,7 @@
#include <assert.h>
#include <netdb.h>
#include <strings.h>
+#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -109,15 +110,22 @@ bool CSocket::read(void* pvData, uint32_t uiSize)
int32_t iAccessedSize = ::recv(_iSockFd, &pucData[uiOffset], uiSize, MSG_NOSIGNAL);
- if (!iAccessedSize || iAccessedSize == -1) {
-
+ switch (iAccessedSize) {
+ case 0:
// recv return value is 0 when the peer has performed an orderly shutdown.
- // -1 if an error occurred
- // In both case the read could not be achieve
return false;
+
+ case -1:
+ // errno == EINTR => The recv system call was interrupted, try again
+ if (errno != EINTR) {
+ return false;
+ }
+ break;
+
+ default:
+ uiSize -= iAccessedSize;
+ uiOffset += iAccessedSize;
}
- uiSize -= iAccessedSize;
- uiOffset += iAccessedSize;
}
return true;
}
@@ -132,13 +140,15 @@ bool CSocket::write(const void* pvData, uint32_t uiSize)
int32_t iAccessedSize = ::send(_iSockFd, &pucData[uiOffset], uiSize, MSG_NOSIGNAL);
- // Return value of 0 is not an error
if (iAccessedSize == -1) {
-
- return false;
+ // errno == EINTR => The send system call was interrupted, try again
+ if (errno != EINTR) {
+ return false;
+ }
+ } else {
+ uiSize -= iAccessedSize;
+ uiOffset += iAccessedSize;
}
- uiSize -= iAccessedSize;
- uiOffset += iAccessedSize;
}
return true;
}