]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
Plug mutex/rwlock leaks (destroy them)
[openldap] / servers / slapd / backend.c
index ed395457350855a149580ea754cc50403ddf26c5..c47e2373e1494192e84e47a44187bee8c957238f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -471,6 +471,8 @@ void backend_destroy_one( BackendDB *bd, int dynamic )
                ber_bvarray_free( bd->be_update_refs );
        }
 
+       ldap_pvt_thread_mutex_destroy( &bd->be_pcl_mutex );
+
        if ( dynamic ) {
                free( bd );
        }
@@ -620,6 +622,7 @@ backend_db_init(
                /* If we created and linked this be, remove it and free it */
                if ( !b0 ) {
                        LDAP_STAILQ_REMOVE(&backendDB, be, BackendDB, be_next);
+                       ldap_pvt_thread_mutex_destroy( &be->be_pcl_mutex );
                        ch_free( be );
                        be = NULL;
                        nbackends--;
@@ -759,10 +762,10 @@ be_slurp_update( Operation *op )
 int
 be_shadow_update( Operation *op )
 {
-       /* This assumes that all internal ops (connid == -1) on a syncrepl
+       /* This assumes that all internal ops (connid <= -1000) on a syncrepl
         * database are syncrepl operations.
         */
-       return (( SLAP_SYNC_SHADOW( op->o_bd ) && op->o_connid == -1 ) ||
+       return ( ( SLAP_SYNC_SHADOW( op->o_bd ) && SLAPD_SYNC_IS_SYNCCONN( op->o_connid ) ) ||
                ( SLAP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn ) ) );
 }
 
@@ -1965,3 +1968,12 @@ int backend_operational( Operation *op, SlapReply *rs )
        return rc;
 }
 
+/* helper that calls the bi_tool_entry_first_x() variant with default args;
+ * use to initialize a backend's bi_tool_entry_first() when appropriate
+ */
+ID
+backend_tool_entry_first( BackendDB *be )
+{
+       return be->bd_info->bi_tool_entry_first_x( be,
+               NULL, LDAP_SCOPE_DEFAULT, NULL );
+}