]> git.sur5r.net Git - openldap/commitdiff
Serialize access to idl insert/delete key routines (ITS 1359)
authorMark Adamson <adamson@openldap.org>
Thu, 11 Oct 2001 18:12:53 +0000 (18:12 +0000)
committerMark Adamson <adamson@openldap.org>
Thu, 11 Oct 2001 18:12:53 +0000 (18:12 +0000)
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/key.c

index ca78ab336a8ae608b2985feec5469af662c814f6..b166f8f35b5c6d78ced36bf3ec691562db03ac93 100644 (file)
@@ -117,6 +117,7 @@ typedef struct ldbm_dbcache {
        long    dbc_blksize;
        char    *dbc_name;
        LDBM    dbc_db;
+       ldap_pvt_thread_mutex_t dbc_write_mutex;
 } DBCache;
 
 #define MAXDBCACHE     128
index 3876bbb5217e007bd3e2137e688d4ca528f3014a..36e19e9771e6fa22f41337335df945d5720cd5bb 100644 (file)
@@ -207,6 +207,8 @@ ldbm_cache_open(
        Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 );
 #endif
 
+       ldap_pvt_thread_mutex_init( &li->li_dbcache[i].dbc_write_mutex );
+
        ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
        return( &li->li_dbcache[i] );
 }
@@ -241,6 +243,7 @@ ldbm_cache_really_close( Backend *be, DBCache *db )
                ldbm_close( db->dbc_db );
                free( db->dbc_name );
                db->dbc_name = NULL;
+               ldap_pvt_thread_mutex_destroy( &db->dbc_write_mutex );
        }
        ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
 }
index 57340fd9a60b0f3b8d28bef42766e0c553d253a6..55c016b85c3ea40541d4cf0e7dcfd7eca5688a99 100644 (file)
@@ -72,7 +72,9 @@ dn2id_add(
                        key.dsize = strlen( pdn ) + 2;
                        key.dptr = ch_malloc( key.dsize );
                        sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
+                       ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
                        rc = idl_insert_key( be, db, key, id );
+                       ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
                        free( key.dptr );
                        free( pdn );
                }
@@ -89,9 +91,9 @@ dn2id_add(
                                key.dptr = ch_malloc( key.dsize );
                                sprintf( key.dptr, "%c%s",
                                        DN_SUBTREE_PREFIX, subtree[i] );
-
+                               ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
                                rc = idl_insert_key( be, db, key, id );
-
+                               ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
                                free( key.dptr );
 
                                if(rc == -1) break;
@@ -298,7 +300,9 @@ dn2id_delete(
                        key.dptr = ch_malloc( key.dsize );
                        sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
 
+                       ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
                        (void) idl_delete_key( be, db, key, id );
+                       ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
 
                        free( key.dptr );
                        free( pdn );
@@ -317,7 +321,9 @@ dn2id_delete(
                                sprintf( key.dptr, "%c%s",
                                        DN_SUBTREE_PREFIX, subtree[i] );
 
+                               ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
                                (void) idl_delete_key( be, db, key, id );
+                               ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
 
                                free( key.dptr );
                        }
index de8b90565eee91e3eb0996a7ba1aac54c2707f6d..69d80075f6b213dd0668decdf0c945d2a32c2351 100644 (file)
@@ -82,6 +82,7 @@ key_change(
        key.dptr = k->bv_val;
        key.dsize = k->bv_len;
 
+       ldap_pvt_thread_mutex_lock( &db->dbc_write_mutex );
        if (op == SLAP_INDEX_ADD_OP) {
            /* Add values */
            rc = idl_insert_key( be, db, key, id );
@@ -90,6 +91,7 @@ key_change(
            /* Delete values */
            rc = idl_delete_key( be, db, key, id );
        }
+       ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
 
 
 #ifdef NEW_LOGGING