Blame SOURCES/0031-Ticket-49410-opened-connection-can-remain-no-longer-.patch

96373c
From 11cea14acfc11d0328013b61a3e1396e97dfe577 Mon Sep 17 00:00:00 2001
8a4a2a
From: Thierry Bordaz <tbordaz@redhat.com>
96373c
Date: Tue, 14 Nov 2017 16:29:03 +0100
8a4a2a
Subject: [PATCH] Ticket 49410 - opened connection can remain no longer poll,
8a4a2a
 like hanging
8a4a2a
8a4a2a
Bug Description:
96373c
	Some opened connection are no longer poll.
96373c
	Those connections has 'gettingber' toggle set although there is
96373c
	no more worker thread reading it.
96373c
	The reason they have gettingber set is that the last
96373c
	operation had 'persistent search' flag. With such flag
96373c
	gettingber is not reset.
96373c
	persistent flag is set even when no persistent search/sync_repl
96373c
	was received on the connection.
96373c
	The problem is that the flag is tested on the wrong operation.
96373c
	The tested operation can be
96373c
		- the first operation when the connection entered in turbo mode
96373c
		- the previous operation if several ops PDUs were read on the network
96373c
		- accessing random memory
96373c
96373c
	In theory testing the flag can lead to sigsev even
96373c
	if it never crash
8a4a2a
8a4a2a
Fix Description:
96373c
	The fix is to use the operation that is in the pblock
96373c
	In such case pb_op is no longer used, so we can get rid of it.
96373c
	In addition make pb_conn a local variable where it is used
8a4a2a
8a4a2a
https://pagure.io/389-ds-base/issue/49410
8a4a2a
8a4a2a
Reviewed by: Ludwig Krispenz, Mark Reynolds
8a4a2a
8a4a2a
Platforms tested: F26
8a4a2a
8a4a2a
Flag Day: no
8a4a2a
8a4a2a
Doc impact: no
8a4a2a
---
96373c
 ldap/servers/slapd/connection.c | 7 +++----
96373c
 1 file changed, 3 insertions(+), 4 deletions(-)
8a4a2a
8a4a2a
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
96373c
index 24a7a1c05..3f19b9765 100644
8a4a2a
--- a/ldap/servers/slapd/connection.c
8a4a2a
+++ b/ldap/servers/slapd/connection.c
96373c
@@ -1498,8 +1498,6 @@ connection_threadmain()
96373c
     int maxthreads = 0;
96373c
     int enable_nunc_stans = 0;
96373c
     long bypasspollcnt = 0;
96373c
-    Connection *pb_conn = NULL;
96373c
-    Operation *pb_op = NULL;
96373c
 
96373c
     enable_nunc_stans = config_get_enable_nunc_stans();
96373c
 #if defined(hpux)
96373c
@@ -1520,6 +1518,8 @@ connection_threadmain()
96373c
         }
8a4a2a
 
96373c
         if (!thread_turbo_flag && !more_data) {
96373c
+	    Connection *pb_conn = NULL;
8a4a2a
+
96373c
             /* If more data is left from the previous connection_read_operation,
96373c
                we should finish the op now.  Client might be thinking it's
96373c
                done sending the request and wait for the response forever.
96373c
@@ -1530,7 +1530,6 @@ connection_threadmain()
96373c
              * Connection wait for new work provides the conn and op for us.
96373c
              */
96373c
             slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
96373c
-            slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
96373c
 
96373c
             switch (ret) {
96373c
             case CONN_NOWORK:
96373c
@@ -1786,7 +1785,7 @@ connection_threadmain()
96373c
         /* total number of ops for the server */
96373c
         slapi_counter_increment(ops_completed);
96373c
         /* If this op isn't a persistent search, remove it */
96373c
-        if (pb_op->o_flags & OP_FLAG_PS) {
96373c
+        if (op->o_flags & OP_FLAG_PS) {
96373c
             PR_EnterMonitor(conn->c_mutex);
96373c
             connection_release_nolock(conn); /* psearch acquires ref to conn - release this one now */
96373c
             PR_ExitMonitor(conn->c_mutex);
8a4a2a
-- 
8a4a2a
2.13.6
8a4a2a