Blame SOURCES/0003-SSS_CLIENT-if-poll-returns-POLLNVAL-then-socket-is-a.patch

a53777
From a40b25a3af29706c058ce5a02dd0ba294dbb6874 Mon Sep 17 00:00:00 2001
a53777
From: Alexey Tikhonov <atikhono@redhat.com>
a53777
Date: Wed, 8 Feb 2023 17:48:52 +0100
a53777
Subject: [PATCH 3/4] SSS_CLIENT: if poll() returns POLLNVAL then socket is
a53777
 alredy closed (or wasn't open) so it shouldn't be closed again. Otherwise
a53777
 there is a risk to close "foreign" socket opened in another thread.
a53777
MIME-Version: 1.0
a53777
Content-Type: text/plain; charset=UTF-8
a53777
Content-Transfer-Encoding: 8bit
a53777
a53777
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
a53777
Reviewed-by: Sumit Bose <sbose@redhat.com>
a53777
(cherry picked from commit ef93284b5a1f196425d9a61e8e24de8972240eb3)
a53777
---
a53777
 src/sss_client/common.c | 18 +++++++++++++++---
a53777
 1 file changed, 15 insertions(+), 3 deletions(-)
a53777
a53777
diff --git a/src/sss_client/common.c b/src/sss_client/common.c
a53777
index 27e09f6f3..c8ade645b 100644
a53777
--- a/src/sss_client/common.c
a53777
+++ b/src/sss_client/common.c
a53777
@@ -159,7 +159,11 @@ static enum sss_status sss_cli_send_req(enum sss_cli_command cmd,
a53777
             *errnop = ETIME;
a53777
             break;
a53777
         case 1:
a53777
-            if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
a53777
+            if (pfd.revents & (POLLERR | POLLHUP)) {
a53777
+                *errnop = EPIPE;
a53777
+            } else if (pfd.revents & POLLNVAL) {
a53777
+                /* Invalid request: fd is not opened */
a53777
+                sss_cli_sd = -1;
a53777
                 *errnop = EPIPE;
a53777
             } else if (!(pfd.revents & POLLOUT)) {
a53777
                 *errnop = EBUSY;
a53777
@@ -270,7 +274,11 @@ static enum sss_status sss_cli_recv_rep(enum sss_cli_command cmd,
a53777
             if (pfd.revents & (POLLHUP)) {
a53777
                 pollhup = true;
a53777
             }
a53777
-            if (pfd.revents & (POLLERR | POLLNVAL)) {
a53777
+            if (pfd.revents & POLLERR) {
a53777
+                *errnop = EPIPE;
a53777
+            } else if (pfd.revents & POLLNVAL) {
a53777
+                /* Invalid request: fd is not opened */
a53777
+                sss_cli_sd = -1;
a53777
                 *errnop = EPIPE;
a53777
             } else if (!(pfd.revents & POLLIN)) {
a53777
                 *errnop = EBUSY;
a53777
@@ -721,7 +729,11 @@ static enum sss_status sss_cli_check_socket(int *errnop,
a53777
             *errnop = ETIME;
a53777
             break;
a53777
         case 1:
a53777
-            if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
a53777
+            if (pfd.revents & (POLLERR | POLLHUP)) {
a53777
+                *errnop = EPIPE;
a53777
+            } else if (pfd.revents & POLLNVAL) {
a53777
+                /* Invalid request: fd is not opened */
a53777
+                sss_cli_sd = -1;
a53777
                 *errnop = EPIPE;
a53777
             } else if (!(pfd.revents & (POLLIN | POLLOUT))) {
a53777
                 *errnop = EBUSY;
a53777
-- 
a53777
2.37.3
a53777