]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9045 rlock only if there may be other threads
authorOndřej Kuzník <ondra@mistotebe.net>
Mon, 23 Jan 2023 11:48:33 +0000 (11:48 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 30 Jan 2023 18:59:26 +0000 (18:59 +0000)
We can't rlock if we've registered ourselves as a writer. We can only
figure that out by checking if we're the thread that initiated the
pause: is the server paused already?

include/ldap_pvt_thread.h
libraries/libldap/tpool.c
servers/slapd/bconfig.c

index 037d6e966a959b1edd6fc1497cd04064413fb5a5..20f5fb8c1e9697b373cfc0d74cd3eb4c4a23c36f 100644 (file)
@@ -253,7 +253,8 @@ typedef enum {
        LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,
        LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX,
        LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,
-       LDAP_PVT_THREAD_POOL_PARAM_STATE
+       LDAP_PVT_THREAD_POOL_PARAM_STATE,
+       LDAP_PVT_THREAD_POOL_PARAM_PAUSED
 } ldap_pvt_thread_pool_param_t;
 #endif /* !LDAP_PVT_THREAD_H_DONE */
 
index 797d59e8410bc2963d9718e7be02b8c8bfcc2cb6..86234643c9d1d183497db97055eb985f65307469 100644 (file)
@@ -769,6 +769,12 @@ ldap_pvt_thread_pool_query(
                }
                break;
 
+       case LDAP_PVT_THREAD_POOL_PARAM_PAUSED:
+               ldap_pvt_thread_mutex_lock(&pool->ltp_mutex);
+               count = (pool->ltp_pause == PAUSED);
+               ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
+               break;
+
        case LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN:
                break;
        }
index 4e00802723f5f5573a3b467aef1f91908b4f1dfd..52fe6ad67c694693937668f9ce9d64334c3b3ce6 100644 (file)
@@ -6979,13 +6979,16 @@ int config_back_entry_get(
        CfBackInfo *cfb;
        CfEntryInfo *ce, *last;
        Entry *e = NULL;
-       int locked = 0, rc = LDAP_NO_SUCH_OBJECT;
+       int paused = 0, rc = LDAP_NO_SUCH_OBJECT;
 
        cfb = (CfBackInfo *)op->o_bd->be_private;
 
-       if ( !ldap_pvt_thread_pool_pausequery( &connection_pool ) ) {
+       if ( ldap_pvt_thread_pool_query( &connection_pool,
+                       LDAP_PVT_THREAD_POOL_PARAM_PAUSED, &paused ) ) {
+               return -1;
+       }
+       if ( !paused ) {
                ldap_pvt_thread_rdwr_rlock( &cfb->cb_rwlock );
-               locked = 1;
        }
        ce = config_find_base( cfb->cb_root, ndn, &last );
        if ( ce ) {
@@ -7001,7 +7004,7 @@ int config_back_entry_get(
        if ( e ) {
                *ent = entry_dup( e );
        }
-       if ( locked )
+       if ( !paused )
                ldap_pvt_thread_rdwr_runlock( &cfb->cb_rwlock );
 
        return rc;