]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/config.c
don't dereference NULL pointers
[openldap] / servers / slapd / back-bdb / config.c
index eda23ebd4edae98e5cdc45caf94c562a4b31e9dd..adf5747a40e44e3b615d392fd2c4fbe43ec993db 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2007 The OpenLDAP Foundation.
+ * Copyright 2000-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -202,7 +202,6 @@ bdb_online_index( void *ctx, void *arg )
        DBT key, data;
        DB_TXN *txn;
        DB_LOCK lock;
-       BDB_LOCKER locker;
        ID id, nid;
        EntryInfo *ei;
        int rc, getnext = 1;
@@ -231,7 +230,6 @@ bdb_online_index( void *ctx, void *arg )
                rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &txn, bdb->bi_db_opflags );
                if ( rc ) 
                        break;
-               locker = TXN_ID( txn );
                if ( getnext ) {
                        getnext = 0;
                        BDB_ID2DISK( id, &nid );
@@ -257,7 +255,7 @@ bdb_online_index( void *ctx, void *arg )
                }
 
                ei = NULL;
-               rc = bdb_cache_find_id( op, txn, id, &ei, 0, locker, &lock );
+               rc = bdb_cache_find_id( op, txn, id, &ei, 0, &lock );
                if ( rc ) {
                        TXN_ABORT( txn );
                        if ( rc == DB_LOCK_DEADLOCK ) {
@@ -337,9 +335,9 @@ bdb_cf_cleanup( ConfigArgs *c )
        
        if ( bdb->bi_flags & BDB_RE_OPEN ) {
                bdb->bi_flags ^= BDB_RE_OPEN;
-               rc = c->be->bd_info->bi_db_close( c->be, NULL );
+               rc = c->be->bd_info->bi_db_close( c->be, &c->reply );
                if ( rc == 0 )
-                       rc = c->be->bd_info->bi_db_open( c->be, NULL );
+                       rc = c->be->bd_info->bi_db_open( c->be, &c->reply );
                /* If this fails, we need to restart */
                if ( rc ) {
                        slapd_shutdown = 2;
@@ -483,9 +481,11 @@ bdb_cf_gen( ConfigArgs *c )
                        if ( bdb->bi_txn_cp_task ) {
                                struct re_s *re = bdb->bi_txn_cp_task;
                                bdb->bi_txn_cp_task = NULL;
+                               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                                if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) )
                                        ldap_pvt_runqueue_stoptask( &slapd_rq, re );
                                ldap_pvt_runqueue_remove( &slapd_rq, re );
+                               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                        }
                        bdb->bi_txn_cp = 0;
                        break;
@@ -620,9 +620,11 @@ bdb_cf_gen( ConfigArgs *c )
                                                c->log );
                                        return 1;
                                }
+                               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                                bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq,
                                        bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb,
                                        LDAP_XSTRING(bdb_checkpoint), c->be->be_suffix[0].bv_val );
+                               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                        }
                }
                } break;
@@ -747,9 +749,11 @@ bdb_cf_gen( ConfigArgs *c )
                                        c->log );
                                return 1;
                        }
+                       ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                        bdb->bi_index_task = ldap_pvt_runqueue_insert( &slapd_rq, 36000,
                                bdb_online_index, c->be,
                                LDAP_XSTRING(bdb_online_index), c->be->be_suffix[0].bv_val );
+                       ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                }
                break;