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:40:32 -0500 |
commit | cc235ca836183ad889abb5cbc7f7b4f02b9668f5 (patch) | |
tree | 2361c16ccd2e42a55d8d8a4b4870c6da794e2933 /sss_client/common.c | |
parent | b8fdafa3b553592a683b8eb657d8a7bdb129673e (diff) | |
download | sssd-cc235ca836183ad889abb5cbc7f7b4f02b9668f5.tar.gz sssd-cc235ca836183ad889abb5cbc7f7b4f02b9668f5.tar.bz2 sssd-cc235ca836183ad889abb5cbc7f7b4f02b9668f5.zip |
Properly handle EINTR from poll()
Diffstat (limited to 'sss_client/common.c')
-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; |