35 lines
1.5 KiB
Diff
35 lines
1.5 KiB
Diff
|
From ccff99df6741e7e6bdc9f9aba3a05f9288efdd3b Mon Sep 17 00:00:00 2001
|
||
|
From: progier389 <progier@redhat.com>
|
||
|
Date: Mon, 7 Aug 2023 10:18:19 +0200
|
||
|
Subject: [PATCH] Issue 5883 - Remove connection mutex contention risk on
|
||
|
autobind (#5886)
|
||
|
|
||
|
Problem: A contention on the connection c_mutex is blocking the listener thread when autobind is performed.
|
||
|
Solution: Let the listener thread skip the connection if the mutex is held by another thread
|
||
|
Reviewed by: @mreynolds389 , @droideck Thanks
|
||
|
|
||
|
(cherry picked from commit 599db0a450357e804072ca03421c9f65351cdf1f)
|
||
|
---
|
||
|
ldap/servers/slapd/daemon.c | 8 +++++++-
|
||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
|
||
|
index e5b7d6e06a..e44d0c9b5b 100644
|
||
|
--- a/ldap/servers/slapd/daemon.c
|
||
|
+++ b/ldap/servers/slapd/daemon.c
|
||
|
@@ -1675,7 +1675,13 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll __attribute__((unused
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
- pthread_mutex_lock(&(c->c_mutex));
|
||
|
+ /* Try to get connection mutex, if not available just skip the connection and
|
||
|
+ * process other connections events. May generates cpu load for listening thread
|
||
|
+ * if connection mutex is held for a long time
|
||
|
+ */
|
||
|
+ if (pthread_mutex_trylock(&(c->c_mutex)) == EBUSY) {
|
||
|
+ continue;
|
||
|
+ }
|
||
|
if (connection_is_active_nolock(c) && c->c_gettingber == 0) {
|
||
|
PRInt16 out_flags;
|
||
|
short readready;
|