diff options
author | Pavel Březina <pbrezina@redhat.com> | 2012-10-04 11:42:59 +0200 |
---|---|---|
committer | Pavel Březina <pbrezina@redhat.com> | 2012-10-08 13:13:41 +0200 |
commit | d76112e1d016dbc262ea0c04c91042d71099c470 (patch) | |
tree | 48fc0efb5de35fbd977137a2335f5370ba4dafa4 | |
parent | a87ffe4ae575369981df90de109ca339bed8787a (diff) | |
download | sssd_unused-d76112e1d016dbc262ea0c04c91042d71099c470.tar.gz sssd_unused-d76112e1d016dbc262ea0c04c91042d71099c470.tar.xz sssd_unused-d76112e1d016dbc262ea0c04c91042d71099c470.zip |
do not fail if POLLHUP occurs while reading data
This cause troubles when we send data to a pipe and close the
file descriptor before data is read. The pipe is still readable,
but POLLHUP is detected and we fail to read them.
For example, this may cause a user beeing unable to log in.
Now if POLLHUP appears, we read the pipe and then close it on
the client side too.
-rw-r--r-- | src/sss_client/common.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 5b175159..1ef3ba15 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -195,6 +195,7 @@ static enum sss_status sss_cli_recv_rep(enum sss_cli_command cmd, uint32_t header[4]; size_t datarecv; uint8_t *buf = NULL; + bool pollhup = false; int len; int ret; @@ -235,7 +236,10 @@ static enum sss_status sss_cli_recv_rep(enum sss_cli_command cmd, *errnop = ETIME; break; case 1: - if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { + if (pfd.revents & (POLLHUP)) { + pollhup = true; + } + if (pfd.revents & (POLLERR | POLLNVAL)) { *errnop = EPIPE; } if (!(pfd.revents & POLLIN)) { @@ -322,6 +326,10 @@ static enum sss_status sss_cli_recv_rep(enum sss_cli_command cmd, } } + if (pollhup) { + sss_cli_close_socket(); + } + *_len = len; *_buf = buf; |