From f3333b9dbeda33a9344b458accaa4ff372adb660 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Fri, 3 Feb 2023 11:35:42 +0100 Subject: [PATCH 2/4] SSS_CLIENT: fix error codes returned by common read/write/check helpers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's kind of expected that in case `(POLLERR | POLLHUP | POLLNVAL)` error condition is detected, regular `POLLIN/POLLOUT` won't be set. Error code set by error condition should have a priority. This enables users of this helper to retry attempt (as designed). Reviewed-by: Pavel Březina Reviewed-by: Sumit Bose (cherry picked from commit 0b8638d8de435384562f17d041655887b73523cd) --- src/sss_client/common.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 2c888faa9..27e09f6f3 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -161,8 +161,7 @@ static enum sss_status sss_cli_send_req(enum sss_cli_command cmd, case 1: if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { *errnop = EPIPE; - } - if (!(pfd.revents & POLLOUT)) { + } else if (!(pfd.revents & POLLOUT)) { *errnop = EBUSY; } break; @@ -273,8 +272,7 @@ static enum sss_status sss_cli_recv_rep(enum sss_cli_command cmd, } if (pfd.revents & (POLLERR | POLLNVAL)) { *errnop = EPIPE; - } - if (!(pfd.revents & POLLIN)) { + } else if (!(pfd.revents & POLLIN)) { *errnop = EBUSY; } break; @@ -725,8 +723,7 @@ static enum sss_status sss_cli_check_socket(int *errnop, case 1: if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { *errnop = EPIPE; - } - if (!(pfd.revents & (POLLIN | POLLOUT))) { + } else if (!(pfd.revents & (POLLIN | POLLOUT))) { *errnop = EBUSY; } break; -- 2.37.3