Blame SOURCES/0083-Ticket-48341-deadlock-on-connection-mutex.patch

400eba
From 666fdac51b94450391e8fec8d16db34db09502ae Mon Sep 17 00:00:00 2001
400eba
From: Ludwig Krispenz <lkrispen@redhat.com>
400eba
Date: Wed, 13 Jan 2016 13:15:53 +0100
400eba
Subject: [PATCH] Ticket: 48341 - deadlock on connection mutex
400eba
400eba
If  thread is blocked in connection_read_operation() it holds the connection mutex
400eba
and the main thread iterating through the connection table is also blocked.
400eba
400eba
But if the main thread would get the mutex it would just detect that the connection has still the
400eba
C_gettingber flag set and immediately release the lock.
400eba
400eba
The check if c_gettingber == 0 can be done without holding the mutex and so the deadlock
400eba
can be avoided
400eba
400eba
Reviewed by Rich, Thanks
400eba
400eba
(cherry picked from commit a1635fc45f681ed9066f6beed9be7e1672490f9f)
400eba
---
400eba
 ldap/servers/slapd/daemon.c | 3 +++
400eba
 1 file changed, 3 insertions(+)
400eba
400eba
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
400eba
index 355f0fc..d25c44d 100644
400eba
--- a/ldap/servers/slapd/daemon.c
400eba
+++ b/ldap/servers/slapd/daemon.c
400eba
@@ -1740,6 +1740,9 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
400eba
 	{
400eba
 		if ( c->c_mutex != NULL )
400eba
 		{
400eba
+			/* this check can be done without acquiring the mutex */
400eba
+			if (c->c_gettingber) continue;
400eba
+
400eba
 			PR_EnterMonitor(c->c_mutex);
400eba
 			if ( connection_is_active_nolock (c) && c->c_gettingber == 0 )
400eba
 			{
400eba
-- 
400eba
2.4.3
400eba