]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb2/txn.c
Change 'unsigned long len' to ber_len_t in get_filter()
[openldap] / servers / slapd / back-bdb2 / txn.c
index cc389deb79b90b58df6bc6531c1f476d71989305..b2e2b0721f5ef9e0767931e65a68a0c2a2431240 100644 (file)
@@ -1,5 +1,10 @@
 /* txn.c - TP support functions of the bdb2 backend */
 
+#include "portable.h"
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #include "txn.h"
 
 
@@ -51,8 +56,9 @@ bdb2i_init_db_file_cache( struct ldbminfo *li, BDB2_TXN_FILES *fileinfo )
 
        fileinfo->dbc_refcnt = 1;
 
-       sprintf( buf, "%s%s%s", li->li_directory, DEFAULT_DIRSEP,
-                                       fileinfo->dbc_name );
+       sprintf( buf, "%s" LDAP_DIRSEP "%s",
+               li->li_directory, fileinfo->dbc_name );
+
        if ( stat( buf, &st ) == 0 ) {
                fileinfo->dbc_blksize = st.st_blksize;
        } else {
@@ -133,8 +139,8 @@ bdb2i_txn_attr_config(
                        if ( open && strcasecmp( fileName, "objectclass" )) {
 
                                /*  re-use filename to get the complete path  */
-                               sprintf( fileName, "%s%s%s",
-                                                       li->li_directory, DEFAULT_DIRSEP, p->dbc_name );
+                               sprintf( fileName, "%s" LDAP_DIRSEP "%s",
+                                                       li->li_directory, p->dbc_name );
 
                                /*  since we have an mpool, we should not define a cache size */
                                p->dbc_db = bdb2i_db_open( fileName, DB_TYPE,
@@ -180,8 +186,8 @@ bdb2i_open_nextid( BackendDB *be )
        DB_INFO                 dbinfo;
        char            fileName[MAXPATHLEN];
 
-       sprintf( fileName, "%s%s%s",
-                               li->li_directory, DEFAULT_DIRSEP, NEXTID_NAME );
+       sprintf( fileName, "%s" LDAP_DIRSEP "%s",
+                               li->li_directory, NEXTID_NAME );
 
        /*  try to open the file for read and write  */
        memset( &dbinfo, 0, sizeof( dbinfo ));
@@ -224,8 +230,8 @@ bdb2i_txn_open_files( BackendDB *be )
        for ( dbFile = head->dbFiles; dbFile; dbFile = dbFile->next ) {
                char   fileName[MAXPATHLEN];
 
-               sprintf( fileName, "%s%s%s",
-                                       li->li_directory, DEFAULT_DIRSEP, dbFile->dbc_name );
+               sprintf( fileName, "%s" LDAP_DIRSEP "%s",
+                                       li->li_directory, dbFile->dbc_name );
 
                /*  since we have an mpool, we should not define a cache size */
                dbFile->dbc_db = bdb2i_db_open( fileName, DB_TYPE,
@@ -272,7 +278,8 @@ bdb2i_txn_close_files( BackendDB *be )
 
        }
 
-       ldbm_close( head->nextidFile );
+       if ( head->nextidFile )
+               ldbm_close( head->nextidFile );
 
 }
 
@@ -316,10 +323,11 @@ bdb2i_check_additional_attr_index( struct ldbminfo *li )
        struct dirent  *file;
 
        if ( ( datadir = opendir( li->li_directory ) ) == NULL ) {
+               int err = errno;
 
                Debug( LDAP_DEBUG_ANY,
        "bdb2i_check_additional_attr_index(): ERROR while opening datadir: %s\n",
-                               strerror( errno ), 0, 0 );
+                               strerror( err ), 0, 0 );
                return( 1 );
 
        }
@@ -652,6 +660,7 @@ bdb2i_db_nextkey( LDBM ldbm, Datum key, DBC *dbcp )
        int             rc;
 
        ldbm_datum_init( data );
+       ldbm_datum_free( ldbm, key );
        key.flags = data.flags = DB_DBT_MALLOC;
 
        if ( (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT ) == 0 ) {
@@ -688,8 +697,9 @@ bdb2i_start_transction( DB_TXNMGR *txmgr )
        txn_do_abort = 0;
 
        if (( rc = txn_begin( txmgr, NULL, &txnid )) != 0 ) {
+               int err = errno;
                Debug( LDAP_DEBUG_ANY, "bdb2i_start_transction failed: %d: errno=%s\n",
-                                       rc, strerror( errno ), 0 );
+                                       rc, strerror( err ), 0 );
 
                if ( txnid != NULL )
                        (void) txn_abort( txnid );
@@ -764,10 +774,7 @@ bdb2i_set_txn_checkpoint( DB_TXNMGR *txmgr, int forced )
                logsize = forced ? (u_int32_t) 0 : txn_max_pending_log;
                mins    = forced ? (u_int32_t) 0 : txn_max_pending_time;
 
-               ldap_pvt_thread_mutex_lock( &currenttime_mutex );
-               time( &currenttime );
-               now = currenttime;
-               ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
+               now = slap_get_time();
 
                rc = txn_checkpoint( txmgr, logsize, mins );