summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-17 07:39:38 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-17 16:37:47 -0500
commit50c777bca3de244c670cf431dcc4c47b60d17f54 (patch)
tree3a1eeb177ac7433d5381e38570ffbd9896067620
parentbfd179a1d0f21eaae6b8788f01401d95e11eab3a (diff)
downloadsssd-50c777bca3de244c670cf431dcc4c47b60d17f54.tar.gz
sssd-50c777bca3de244c670cf431dcc4c47b60d17f54.tar.xz
sssd-50c777bca3de244c670cf431dcc4c47b60d17f54.zip
Properly handle EINTR from poll()
-rw-r--r--sss_client/common.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/sss_client/common.c b/sss_client/common.c
index 91b65cdca..6732c24fc 100644
--- a/sss_client/common.c
+++ b/sss_client/common.c
@@ -75,16 +75,26 @@ static enum nss_status sss_nss_send_req(enum sss_cli_command cmd,
while (datasent < header[0]) {
struct pollfd pfd;
int rdsent;
- int res;
+ int res, error;
*errnop = 0;
pfd.fd = sss_cli_sd;
pfd.events = POLLOUT;
- res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ do {
+ errno = 0;
+ res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ error = errno;
+
+ /* If error is EINTR here, we'll try again
+ * If it's any other error, we'll catch it
+ * below.
+ */
+ } while (error == EINTR);
+
switch (res) {
case -1:
- *errnop = errno;
+ *errnop = error;
break;
case 0:
*errnop = ETIME;
@@ -155,20 +165,30 @@ static enum nss_status sss_nss_recv_rep(enum sss_cli_command cmd,
datarecv = 0;
*buf = NULL;
*len = 0;
+ *errnop = 0;
while (datarecv < header[0]) {
struct pollfd pfd;
int bufrecv;
- int res;
+ int res, error;
- *errnop = 0;
pfd.fd = sss_cli_sd;
pfd.events = POLLIN;
- res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ do {
+ errno = 0;
+ res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ error = errno;
+
+ /* If error is EINTR here, we'll try again
+ * If it's any other error, we'll catch it
+ * below.
+ */
+ } while (error == EINTR);
+
switch (res) {
case -1:
- *errnop = errno;
+ *errnop = error;
break;
case 0:
*errnop = ETIME;
@@ -528,16 +548,26 @@ static enum sss_status sss_cli_check_socket(int *errnop, const char *socket_name
/* check if the socket has been closed on the other side */
if (sss_cli_sd != -1) {
struct pollfd pfd;
- int res;
+ int res, error;
*errnop = 0;
pfd.fd = sss_cli_sd;
pfd.events = POLLIN | POLLOUT;
- res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ do {
+ errno = 0;
+ res = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT);
+ error = errno;
+
+ /* If error is EINTR here, we'll try again
+ * If it's any other error, we'll catch it
+ * below.
+ */
+ } while (error == EINTR);
+
switch (res) {
case -1:
- *errnop = errno;
+ *errnop = error;
break;
case 0:
*errnop = ETIME;