]> git.sur5r.net Git - openldap/commitdiff
Code clean-up.
authorKurt Spanier <ksp@openldap.org>
Thu, 18 Feb 1999 15:33:15 +0000 (15:33 +0000)
committerKurt Spanier <ksp@openldap.org>
Thu, 18 Feb 1999 15:33:15 +0000 (15:33 +0000)
servers/slapd/back-bdb2/add.c
servers/slapd/back-bdb2/back-bdb2.h
servers/slapd/back-bdb2/cache.c
servers/slapd/back-bdb2/delete.c
servers/slapd/back-bdb2/init.c
servers/slapd/back-bdb2/modrdn.c
servers/slapd/back-bdb2/nextid.c
tests/scripts/test008-concurrency

index 1fc5d82f7808fac7505633b1a82b7d32e99b4d1d..6d56b48012408d27f47ae3bb10e362b45d784dc7 100644 (file)
@@ -22,24 +22,17 @@ bdb2i_back_add_internal(
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        char            *pdn;
        Entry           *p = NULL;
-       int                     rootlock = 0;
        int                     rc; 
 
        Debug(LDAP_DEBUG_ARGS, "==> bdb2i_back_add: %s\n", e->e_dn, 0, 0);
 
-       /* nobody else can add until we lock our parent */
-       /* DDD ldap_pvt_thread_mutex_lock(&li->li_add_mutex); */
-
        if ( ( bdb2i_dn2id( be, e->e_ndn ) ) != NOID ) {
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
                entry_free( e );
                send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
                return( -1 );
        }
 
        if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
-
                Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
                        0, 0, 0 );
 
@@ -60,7 +53,6 @@ bdb2i_back_add_internal(
 
                /* get parent with writer lock */
                if ( (p = bdb2i_dn2entry_w( be, pdn, &matched )) == NULL ) {
-                       /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
                        Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
@@ -75,9 +67,6 @@ bdb2i_back_add_internal(
                        return -1;
                }
 
-               /* don't need the add lock anymore */
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
-
                free(pdn);
 
                if ( matched != NULL ) {
@@ -102,7 +91,6 @@ bdb2i_back_add_internal(
        } else {
                /* no parent, must be adding entry to root */
                if ( ! be_isroot( be, op->o_ndn ) ) {
-                       /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
                        Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", 0,
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
@@ -111,14 +99,6 @@ bdb2i_back_add_internal(
                        entry_free( e );
                        return -1;
                }
-
-               /*
-                * no parent, acquire the root write lock
-                * and release the add lock.
-                */
-               /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
-               rootlock = 1;
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
        }
 
        e->e_id = bdb2i_next_id( be );
@@ -134,11 +114,6 @@ bdb2i_back_add_internal(
                        bdb2i_cache_return_entry_w( &li->li_cache, p ); 
                }
 
-               if ( rootlock ) {
-                       /* release root lock */
-                       /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
-               }
-
                Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
                    0 );
 
@@ -214,11 +189,6 @@ return_results:;
 
        }
 
-       if ( rootlock ) {
-               /* release root lock */
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
-       }
-
        /* free entry and writer lock */
        bdb2i_cache_return_entry_w( &li->li_cache, e ); 
 
index 0a7bdc1d5b10132274d81be257cba2295e661784..a99efa7bca1cc754f009987c8bd6d1b32bf180da 100644 (file)
@@ -79,7 +79,6 @@ struct cache {
        Avlnode         *c_idtree;
        Entry           *c_lruhead;     /* lru - add accessed entries here */
        Entry           *c_lrutail;     /* lru - rem lru entries from here */
-       /* DDD ldap_pvt_thread_mutex_t  c_mutex; */
 };
 
 #define CACHE_READ_LOCK                1
@@ -182,9 +181,6 @@ struct ldbminfo {
        ID                      li_nextid_wrote;
 #endif
        char            *li_nextid_file;
-       /* DDD ldap_pvt_thread_mutex_t          li_root_mutex; */
-       /* DDD ldap_pvt_thread_mutex_t          li_add_mutex; */
-       /* DDD ldap_pvt_thread_mutex_t          li_nextid_mutex; */
        int                     li_mode;
        char                    *li_directory;
        struct cache            li_cache;
index b17aadab2dc9b9e430da65a52e3c537645d03ec9..3374abfa571120c80f2264fe4a533c897a067b36 100644 (file)
 
 /* LDBM backend specific entry info -- visible only to the cache */
 struct ldbm_entry_info {
-       ldap_pvt_thread_rdwr_t  lei_rdwr;       /* reader/writer lock */
-
        /*
-        * remaining fields require backend cache lock to access
         * These items are specific to the LDBM backend and should
         * be hidden.
         */
@@ -38,54 +35,6 @@ static int   cache_delete_entry_internal(struct cache *cache, Entry *e);
 static void    lru_print(struct cache *cache);
 #endif
 
-static int
-cache_entry_rdwr_lock(Entry *e, int rw)
-{
-       Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
-               rw ? "w" : "r", e->e_id, 0);
-
-       if (rw)
-               return ldap_pvt_thread_rdwr_wlock(&LEI(e)->lei_rdwr);
-       else
-               return ldap_pvt_thread_rdwr_rlock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_trylock(Entry *e, int rw)
-{
-       Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %ld\n",
-               rw ? "w" : "r", e->e_id, 0);
-
-       if (rw)
-               return ldap_pvt_thread_rdwr_wtrylock(&LEI(e)->lei_rdwr);
-       else
-               return ldap_pvt_thread_rdwr_rtrylock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_unlock(Entry *e, int rw)
-{
-       Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
-               rw ? "w" : "r", e->e_id, 0);
-
-       if (rw)
-               return ldap_pvt_thread_rdwr_wunlock(&LEI(e)->lei_rdwr);
-       else
-               return ldap_pvt_thread_rdwr_runlock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_init(Entry *e)
-{
-       return ldap_pvt_thread_rdwr_init( &LEI(e)->lei_rdwr );
-}
-
-static int
-cache_entry_rdwr_destroy(Entry *e)
-{
-       return ldap_pvt_thread_rdwr_destroy( &LEI(e)->lei_rdwr );
-}
-
 static int
 cache_entry_private_init( Entry*e )
 {
@@ -102,12 +51,6 @@ cache_entry_private_init( Entry*e )
 
        e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info));
 
-       /* DDD if( cache_entry_rdwr_init( e ) != 0 ) { */
-               /* DDD free( LEI(e) ); */
-               /* DDD e->e_private = NULL; */
-               /* DDD return 1; */
-       /* DDD }  */
-
        return 0;
 }
 
@@ -120,8 +63,6 @@ cache_entry_private_destroy( Entry*e )
        assert( e->e_private );
 #endif
 
-       /* DDD cache_entry_rdwr_destroy( e ); */
-
        free( e->e_private );
        e->e_private = NULL;
        return 0;
@@ -130,15 +71,10 @@ cache_entry_private_destroy( Entry*e )
 void
 bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
 {
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
 #ifdef LDAP_DEBUG
        assert( e->e_private );
 #endif
 
-       /* DDD cache_entry_rdwr_unlock(e, rw); */
-
        LEI(e)->lei_refcnt--;
 
        if ( LEI(e)->lei_state == CACHE_ENTRY_CREATING ) {
@@ -168,9 +104,6 @@ bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
                        "====> bdb2i_cache_return_entry_%s( %ld ): returned (%d)\n",
                        rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt);
        }
-
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
 }
 
 #define LRU_DELETE( cache, e ) { \
@@ -211,12 +144,9 @@ bdb2i_cache_add_entry_rw(
        int             rw
 )
 {
-       int     i, rc;
+       int     i;
        Entry   *ee;
 
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
 #ifdef LDAP_DEBUG
        assert( e->e_private == NULL );
 #endif
@@ -237,8 +167,6 @@ bdb2i_cache_add_entry_rw(
 
                cache_entry_private_destroy(e);
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                return( 1 );
        }
 
@@ -260,13 +188,9 @@ bdb2i_cache_add_entry_rw(
 
                cache_entry_private_destroy(e);
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                return( -1 );
        }
 
-       /* DDD cache_entry_rdwr_lock( e, rw ); */
-
        /* put the entry into 'CREATING' state */
        /* will be marked after when entry is returned */
        LEI(e)->lei_state = CACHE_ENTRY_CREATING;
@@ -303,15 +227,12 @@ bdb2i_cache_add_entry_rw(
                        e = cache->c_lrutail;
 
                        /* delete from cache and lru q */
-                       /* XXX do we need rc ? */
-                       rc = cache_delete_entry_internal( cache, e );
+                       cache_delete_entry_internal( cache, e );
                        cache_entry_private_destroy( e );
                        entry_free( e );
                }
        }
 
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
        return( 0 );
 }
 
@@ -327,12 +248,9 @@ bdb2i_cache_update_entry(
     Entry              *e
 )
 {
-       int     i, rc;
+       int     i;
        Entry   *ee;
 
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
 #ifdef LDAP_DEBUG
        assert( e->e_private );
 #endif
@@ -344,8 +262,6 @@ bdb2i_cache_update_entry(
                "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
                    e->e_id, e->e_dn, 0 );
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                return( 1 );
        }
 
@@ -365,8 +281,6 @@ bdb2i_cache_update_entry(
                            0, 0, 0 );
                }
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                return( -1 );
        }
 
@@ -405,15 +319,12 @@ bdb2i_cache_update_entry(
                        e = cache->c_lrutail;
 
                        /* delete from cache and lru q */
-                       /* XXX do we need rc ? */
-                       rc = cache_delete_entry_internal( cache, e );
+                       cache_delete_entry_internal( cache, e );
                        cache_entry_private_destroy( e );
                        entry_free( e );
                }
        }
 
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
        return( 0 );
 }
 
@@ -432,9 +343,6 @@ bdb2i_cache_find_entry_dn2id(
        Entry           e, *ep;
        ID                      id;
 
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
        e.e_dn = dn;
        e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
 
@@ -463,8 +371,6 @@ bdb2i_cache_find_entry_dn2id(
                        "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
                                dn, ep->e_id, LEI(ep)->lei_state);
 
-                       /* free cache mutex */
-                       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                        return( NOID );
                }
 
@@ -479,17 +385,11 @@ bdb2i_cache_find_entry_dn2id(
                /* save id */
                id = ep->e_id;
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
                return( id );
        }
 
        free(e.e_ndn);
 
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
        return( NOID );
 }
 
@@ -510,9 +410,6 @@ bdb2i_cache_find_entry_id(
        e.e_id = id;
 
 try_again:
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
        if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
                entry_id_cmp )) != NULL )
        {
@@ -531,8 +428,6 @@ try_again:
                                "====> bdb2i_cache_find_entry_id( %ld ): %ld (not ready) %d\n",
                                id, ep->e_id, LEI(ep)->lei_state);
 
-                       /* free cache mutex */
-                       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                        return( NULL );
                }
 
@@ -540,34 +435,15 @@ try_again:
                        "====> bdb2i_cache_find_entry_id( %ld, %s ) \"%s\" (found)\n",
                        id, rw ? "w" : "r", ep->e_dn);
 
-               /* acquire reader lock */
-               /* DDD if ( cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) { */
-                       /* could not acquire entry lock...
-                        * owner cannot free as we have the cache locked.
-                        * so, unlock the cache, yield, and try again.
-                        */
-
-                       /* free cache mutex */
-                       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-                       /* DDD ldap_pvt_thread_yield(); */
-                       /* DDD goto try_again; */
-               /* DDD } */
-
                /* lru */
                LRU_DELETE( cache, ep );
                LRU_ADD( cache, ep );
                 
                LEI(ep)->lei_refcnt++;
 
-               /* free cache mutex */
-               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
                return( ep );
        }
 
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
        return( NULL );
 }
 
@@ -590,9 +466,6 @@ bdb2i_cache_delete_entry(
 {
        int     rc;
 
-       /* set cache mutex */
-       /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
 #ifdef LDAP_DEBUG
        assert( e->e_private );
 #endif
@@ -602,8 +475,6 @@ bdb2i_cache_delete_entry(
 
        rc = cache_delete_entry_internal( cache, e );
 
-       /* free cache mutex */
-       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
        return( rc );
 }
 
index a47c32e88ad6d9ceb9e9a8b4f53cedcffe7aae55..57e910e15f048b189cc3792af475a4ee7afc54c8 100644 (file)
@@ -23,7 +23,6 @@ bdb2i_back_delete_internal(
        char    *matched = NULL;
        char    *pdn = NULL;
        Entry   *e, *p = NULL;
-       int rootlock = 0;
        int     rc = -1;
 
        Debug(LDAP_DEBUG_ARGS, "==> bdb2i_back_delete: %s\n", dn, 0, 0);
@@ -93,9 +92,6 @@ bdb2i_back_delete_internal(
                                "", "");
                        goto return_results;
                }
-
-               /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
-               rootlock = 1;
        }
 
        if ( bdb2i_id2children_remove( be, p, e ) != 0 ) {
@@ -136,11 +132,6 @@ return_results:;
 
        }
 
-       if ( rootlock ) {
-               /* release root lock */
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
-       }
-
        /* free entry and writer lock */
        bdb2i_cache_return_entry_w( &li->li_cache, e );
 
index 115573f7105160937b25698c57b959c41e6c4a12..1892b7e2865a2caf2b1aac0a0c4515d1612ab8fb 100644 (file)
@@ -172,12 +172,6 @@ bdb2i_back_db_init_internal(
            1 );
        free( argv[ 1 ] );
 
-       /* initialize various mutex locks & condition variables */
-       /* DDD ldap_pvt_thread_mutex_init( &li->li_root_mutex ); */
-       /* DDD ldap_pvt_thread_mutex_init( &li->li_add_mutex ); */
-       /* DDD ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex ); */
-       /* DDD ldap_pvt_thread_mutex_init( &li->li_nextid_mutex ); */
-
        /*  initialize the TP file head  */
        if ( bdb2i_txn_head_init( &li->li_txn_head ) != 0 )
                return 1;
index 3f6d077c0626169ca797e137c0df1bfeeff34592..147bc09ca5f5d77abdb332f15bf5da352f4edf6d 100644 (file)
@@ -27,7 +27,6 @@ bdb2i_back_modrdn_internal(
        char            *new_dn = NULL, *new_ndn = NULL;
        char            sep[2];
        Entry           *e, *p = NULL;
-       int                     rootlock = 0;
        int                     rc = -1;
 
        /* get entry with writer lock */
@@ -107,9 +106,6 @@ bdb2i_back_modrdn_internal(
                        goto return_results;
                }
 
-               /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
-               rootlock = 1;
-
                new_dn = ch_strdup( newrdn );
        }
 
@@ -180,11 +176,6 @@ return_results:
 
        }
 
-       if ( rootlock ) {
-               /* release root writer lock */
-               /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
-       }
-
        /* free entry and writer lock */
        bdb2i_cache_return_entry_w( &li->li_cache, e );
        return( rc );
index 9b7937508f5c73e8dfa671c6f0407141a14c3ec2..4021b8e473f968ecd30d59e0716a7d0a97d823ff 100644 (file)
@@ -98,8 +98,6 @@ bdb2i_next_id( BackendDB *be )
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID              id;
 
-       /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
        /* first time in here since startup - try to read the nexid */
        if ( li->li_nextid == NOID ) {
                li->li_nextid = next_id_read( be );
@@ -124,7 +122,6 @@ bdb2i_next_id( BackendDB *be )
        (void) next_id_write( be, li->li_nextid );
 #endif
 
-       /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
        return( id );
 }
 
@@ -134,10 +131,7 @@ bdb2i_next_id_return( BackendDB *be, ID id )
 #ifdef SLAPD_NEXTID_RETURN
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
-       /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
        if ( id != li->li_nextid - 1 ) {
-               /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
                return;
        }
 
@@ -146,8 +140,6 @@ bdb2i_next_id_return( BackendDB *be, ID id )
 #if !( SLAPD_NEXTID_CHUCK > 1 )
        (void) next_id_write( be, li->li_nextid );
 #endif
-
-       /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
 #endif
 }
 
@@ -157,8 +149,6 @@ bdb2i_next_id_get( BackendDB *be )
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID              id;
 
-       /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
        /* first time in here since startup - try to read the nexid */
        if ( li->li_nextid == NOID ) {
                li->li_nextid = next_id_read( be );
@@ -174,7 +164,5 @@ bdb2i_next_id_get( BackendDB *be )
 
        id = li->li_nextid;
 
-       /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
-
        return( id );
 }
index eca68fa2dc43dc58e951678e05ace95715ab04c9..88355b20e12749f42029304cd0e8e2d943968d7b 100755 (executable)
@@ -27,6 +27,9 @@ if [ $RC != 0 ]; then
        exit $RC
 fi
 
+echo "Waiting 5 seconds for ldif2ldbm to build slapd database..."
+sleep 5
+
 echo "Starting slapd on TCP/IP port $PORT..."
 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
 PID=$!