]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/dbcache.c
Happy new year
[openldap] / servers / slapd / back-ldbm / dbcache.c
index 1187e6b2954b667407e8abf1db5081a72838283c..04c21cf3f0cc669c73bfd786980f46c74af420b9 100644 (file)
@@ -1,8 +1,17 @@
 /* ldbmcache.c - maintain a cache of open ldbm files */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
@@ -54,8 +63,8 @@ ldbm_cache_open(
        }
        
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
-                  "ldbm_cache_open: \"%s\", %d, %o\n", buf, flags, li->li_mode ));
+       LDAP_LOG( CACHE, ENTRY, 
+               "ldbm_cache_open: \"%s\", %d, %o\n", buf, flags, li->li_mode );
 #else
        Debug( LDAP_DEBUG_TRACE, "=> ldbm_cache_open( \"%s\", %d, %o )\n", buf,
            flags, li->li_mode );
@@ -101,8 +110,8 @@ ldbm_cache_open(
                                }
                                li->li_dbcache[i].dbc_refcnt++;
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
-                                          "ldbm_cache_open: cache %d\n", i ));
+                               LDAP_LOG( CACHE, DETAIL1, 
+                                       "ldbm_cache_open: cache %d\n", i, 0, 0 );
 #else
                                Debug( LDAP_DEBUG_TRACE,
                                    "<= ldbm_cache_open (cache %d)\n", i, 0, 0 );
@@ -132,8 +141,9 @@ ldbm_cache_open(
                                li->li_dbcache[i].dbc_name = NULL;
                        } else {
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
-                                          "ldbm_cache_open: no unused db to close - waiting\n" ));
+                               LDAP_LOG( CACHE, INFO,
+                                       "ldbm_cache_open: no unused db to close - waiting\n", 
+                                       0, 0, 0 );
 #else
                                Debug( LDAP_DEBUG_ANY,
                                    "ldbm_cache_open no unused db to close - waiting\n",
@@ -155,10 +165,10 @@ ldbm_cache_open(
        {
                int err = errno;
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
-                          "ldbm_cache_open: \"%s\" failed, errono=%d, reason=%s\n",
-                          buf, err, err > -1 && err < sys_nerr ? sys_errlist[err] :
-                          "unknown" ));
+               LDAP_LOG( CACHE, ERR, 
+                       "ldbm_cache_open: \"%s\" failed, errono=%d, reason=%s\n",
+                       buf, err, err > -1 && err < sys_nerr ? sys_errlist[err] :
+                       "unknown" );
 #else
                Debug( LDAP_DEBUG_TRACE,
                    "<= ldbm_cache_open NULL \"%s\" errno=%d reason=\"%s\")\n",
@@ -190,10 +200,10 @@ ldbm_cache_open(
        assert( li->li_dbcache[i].dbc_maxindirect < 256 );
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "cache", LDAP_LEVEL_ARGS,
+       LDAP_LOG( CACHE, ARGS, 
                   "ldbm_cache_open: blksize:%ld  maxids:%d  maxindirect:%d\n",
                   li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids,
-                  li->li_dbcache[i].dbc_maxindirect ));
+                  li->li_dbcache[i].dbc_maxindirect );
 #else
        Debug( LDAP_DEBUG_ARGS,
            "ldbm_cache_open (blksize %ld) (maxids %d) (maxindirect %d)\n",
@@ -202,8 +212,7 @@ ldbm_cache_open(
 #endif
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
-                  "ldbm_cache_open: opened %d\n", i ));
+       LDAP_LOG( CACHE, DETAIL1, "<= ldbm_cache_open: (opened %d)\n", i, 0, 0 );
 #else
        Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 );
 #endif
@@ -259,9 +268,9 @@ ldbm_cache_flush_all( Backend *be )
        for ( i = 0; i < MAXDBCACHE; i++ ) {
                if ( li->li_dbcache[i].dbc_name != NULL ) {
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
+                       LDAP_LOG( CACHE, DETAIL1, 
                                   "ldbm_cache_flush_all: flushing db (%s)\n",
-                                  li->li_dbcache[i].dbc_name ));
+                                  li->li_dbcache[i].dbc_name, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_TRACE, "ldbm flushing db (%s)\n",
                            li->li_dbcache[i].dbc_name, 0, 0 );
@@ -271,9 +280,9 @@ ldbm_cache_flush_all( Backend *be )
                        li->li_dbcache[i].dbc_dirty = 0;
                        if ( li->li_dbcache[i].dbc_refcnt != 0 ) {
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
-                                          "ldbm_cache_flush_all: couldn't close db (%s), refcnt=%d\n",
-                                          li->li_dbcache[i].dbc_name, li->li_dbcache[i].dbc_refcnt ));
+                               LDAP_LOG( CACHE, INFO, 
+                                       "ldbm_cache_flush_all: couldn't close db (%s), refcnt=%d\n",
+                                       li->li_dbcache[i].dbc_name, li->li_dbcache[i].dbc_refcnt,0);
 #else
                                Debug( LDAP_DEBUG_TRACE,
                                       "refcnt = %d, couldn't close db (%s)\n",
@@ -283,9 +292,9 @@ ldbm_cache_flush_all( Backend *be )
 
                        } else {
 #ifdef NEW_LOGGING
-                               LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
+                               LDAP_LOG( CACHE, DETAIL1, 
                                           "ldbm_cache_flush_all: ldbm closing db (%s)\n",
-                                          li->li_dbcache[i].dbc_name ));
+                                          li->li_dbcache[i].dbc_name, 0, 0 );
 #else
                                Debug( LDAP_DEBUG_TRACE,
                                       "ldbm closing db (%s)\n",
@@ -311,8 +320,13 @@ ldbm_cache_sync( Backend *be )
        ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
        for ( i = 0; i < MAXDBCACHE; i++ ) {
                if ( li->li_dbcache[i].dbc_name != NULL && li->li_dbcache[i].dbc_dirty ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync: "
+                               "ldbm syncing db (%s)\n", li->li_dbcache[i].dbc_name, 0, 0 );
+#else
                        Debug(  LDAP_DEBUG_TRACE, "ldbm syncing db (%s)\n",
                                li->li_dbcache[i].dbc_name, 0, 0 );
+#endif
                        ldbm_sync( li->li_dbcache[i].dbc_db );
                        li->li_dbcache[i].dbc_dirty = 0;
                }
@@ -320,6 +334,7 @@ ldbm_cache_sync( Backend *be )
        ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
 }
 
+#if 0 /* macro in proto-back-ldbm.h */
 Datum
 ldbm_cache_fetch(
     DBCache    *db,
@@ -328,6 +343,7 @@ ldbm_cache_fetch(
 {
        return ldbm_fetch( db->dbc_db, key );
 }
+#endif /* 0 */
 
 int
 ldbm_cache_store(
@@ -339,24 +355,6 @@ ldbm_cache_store(
 {
        int     rc;
 
-#ifdef LDBM_DEBUG
-       Statslog( LDAP_DEBUG_STATS,
-               "=> ldbm_cache_store(): key.dptr=%s, key.dsize=%d\n",
-               key.dptr, key.dsize, 0, 0, 0 );
-
-       Statslog( LDAP_DEBUG_STATS,
-               "=> ldbm_cache_store(): key.dptr=0x%08x, data.dptr=0x%0 8x\n",
-               key.dptr, data.dptr, 0, 0, 0 );
-
-       Statslog( LDAP_DEBUG_STATS,
-               "=> ldbm_cache_store(): data.dptr=%s, data.dsize=%d\n",
-               data.dptr, data.dsize, 0, 0, 0 );
-
-       Statslog( LDAP_DEBUG_STATS,
-               "=> ldbm_cache_store(): flags=0x%08x\n",
-               flags, 0, 0, 0, 0 );
-#endif /* LDBM_DEBUG */
-
        db->dbc_dirty = 1;
        rc = ldbm_store( db->dbc_db, key, data, flags );
 
@@ -385,7 +383,12 @@ ldbm_cache_sync_daemon(
        Backend *be = (Backend *)be_ptr;
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CACHE, ARGS, "ldbm_cache_sync_daemon:"
+               " synchronizer starting for %s\n", li->li_directory, 0, 0 );
+#else
        Debug( LDAP_DEBUG_ANY, "synchronizer starting for %s\n", li->li_directory, 0, 0 );
+#endif
   
        while (!li->li_dbshutdown) {
                int i = li->li_dbsyncwaitn;
@@ -393,18 +396,33 @@ ldbm_cache_sync_daemon(
                sleep( li->li_dbsyncfreq );
 
                while (i && ldap_pvt_thread_pool_backload(&connection_pool) != 0) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:"
+                               " delay syncing %s\n", li->li_directory, 0, 0 );
+#else
                        Debug( LDAP_DEBUG_TRACE, "delay syncing %s\n", li->li_directory, 0, 0 );
+#endif
                        sleep(li->li_dbsyncwaitinterval);
                        i--;
                }
 
                if (!li->li_dbshutdown) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:"
+                               " syncing %s\n", li->li_directory, 0, 0 );
+#else
                        Debug( LDAP_DEBUG_TRACE, "syncing %s\n", li->li_directory, 0, 0 );
+#endif
                        ldbm_cache_sync( be );
                }
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG ( CACHE, DETAIL1, "ldbm_cache_sync_daemon:"
+                               " synchronizer stopping\n", 0, 0, 0);
+#else
        Debug( LDAP_DEBUG_ANY, "synchronizer stopping\n", 0, 0, 0 );
+#endif
   
        return NULL;
 }