]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
ITS#6932: Clean up strange asserts & nearby code.
[openldap] / servers / slapd / backend.c
index 58ec6ffb6f81649ee30858343a44675772da895f..006c47370e97297b14fc0de87d38d3d13e155b85 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2010 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -474,6 +474,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 );
        }
@@ -623,6 +625,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--;
@@ -1051,7 +1054,7 @@ backend_check_restrictions(
                requires |= op->o_bd->be_requires;
                bssf = &op->o_bd->be_ssf_set.sss_ssf;
                fssf = &ssfs.sss_ssf;
-               for ( i=0; i<sizeof(ssfs)/sizeof(slap_ssf_t); i++ ) {
+               for ( i=0; i < (int)(sizeof(ssfs)/sizeof(slap_ssf_t)); i++ ) {
                        if ( bssf[i] ) fssf[i] = bssf[i];
                }
        }
@@ -1673,7 +1676,7 @@ fe_acl_attribute(
 
                a = attr_find( e->e_attrs, entry_at );
                if ( a == NULL ) {
-                       SlapReply       rs = { 0 };
+                       SlapReply       rs = { REP_SEARCH };
                        AttributeName   anlist[ 2 ];
 
                        anlist[ 0 ].an_name = entry_at->ad_cname;
@@ -1686,8 +1689,7 @@ fe_acl_attribute(
                         * to do no harm to entries */
                        rs.sr_entry = e;
                        rc = backend_operational( op, &rs );
-                       rs.sr_entry = NULL;
+
                        if ( rc == LDAP_SUCCESS ) {
                                if ( rs.sr_operational_attrs ) {
                                        freeattr = 1;
@@ -1792,9 +1794,9 @@ backend_access(
        slap_mask_t             *mask )
 {
        Entry           *e = NULL;
-       void            *o_priv = op->o_private, *e_priv = NULL;
+       void            *o_priv, *e_priv = NULL;
        int             rc = LDAP_INSUFFICIENT_ACCESS;
-       Backend         *be = op->o_bd;
+       Backend         *be;
 
        /* pedantic */
        assert( op != NULL );
@@ -1802,6 +1804,9 @@ backend_access(
        assert( edn != NULL );
        assert( access > ACL_NONE );
 
+       be = op->o_bd;
+       o_priv = op->o_private;
+
        if ( !op->o_bd ) {
                op->o_bd = select_backend( edn, 0 );
        }
@@ -1838,7 +1843,7 @@ backend_access(
                } else {
                        a = attr_find( e->e_attrs, entry_at );
                        if ( a == NULL ) {
-                               SlapReply       rs = { 0 };
+                               SlapReply       rs = { REP_SEARCH };
                                AttributeName   anlist[ 2 ];
 
                                anlist[ 0 ].an_name = entry_at->ad_cname;
@@ -1853,7 +1858,6 @@ backend_access(
                                 * to do no harm to entries */
                                rs.sr_entry = e;
                                rc = backend_operational( op, &rs );
-                               rs.sr_entry = NULL;
 
                                if ( rc == LDAP_SUCCESS ) {
                                        if ( rs.sr_operational_attrs ) {