diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-17 07:39:38 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-17 16:37:47 -0500 |
commit | 50c777bca3de244c670cf431dcc4c47b60d17f54 (patch) | |
tree | 3a1eeb177ac7433d5381e38570ffbd9896067620 /sss_client | |
parent | bfd179a1d0f21eaae6b8788f01401d95e11eab3a (diff) | |
download | sssd_unused-50c777bca3de244c670cf431dcc4c47b60d17f54.tar.gz sssd_unused-50c777bca3de244c670cf431dcc4c47b60d17f54.tar.xz sssd_unused-50c777bca3de244c670cf431dcc4c47b60d17f54.zip |
Properly handle EINTR from poll()
Diffstat (limited to 'sss_client')
-rw-r--r-- | sss_client/common.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/sss_client/common.c b/sss_client/common.c index 91b65cdc..6732c24f 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; |