]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/back-bdb.h
Unify use of BDB lockers
[openldap] / servers / slapd / back-bdb / back-bdb.h
index ca6bd83c51f4a0a575f35a54abf26c603e3645ea..534062b53d7d72c8989f614e6e5a3ceaef725581 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -68,9 +68,9 @@ LDAP_BEGIN_DECL
 
 typedef struct bdb_idl_cache_entry_s {
        struct berval kstr;
-       ldap_pvt_thread_rdwr_t idl_entry_rwlock;
        ID      *idl;
        DB      *db;
+       int             idl_flags;
        struct bdb_idl_cache_entry_s* idl_lru_prev;
        struct bdb_idl_cache_entry_s* idl_lru_next;
 } bdb_idl_cache_entry_t;
@@ -94,6 +94,7 @@ typedef struct bdb_entry_info {
 #define        CACHE_ENTRY_LOADING     0x10
 #define        CACHE_ENTRY_WALKING     0x20
 #define        CACHE_ENTRY_ONELEVEL    0x40
+#define        CACHE_ENTRY_REFERENCED  0x80
 
        /*
         * remaining fields require backend cache lock to access
@@ -121,18 +122,21 @@ typedef struct bdb_entry_info {
 
 /* for the in-core cache of entries */
 typedef struct bdb_cache {
-       int             c_maxsize;
-       int             c_cursize;
-       int             c_eiused;       /* EntryInfo's in use */
-       int             c_leaves;       /* EntryInfo leaf nodes */
-       EntryInfo       c_dntree;
        EntryInfo       *c_eifree;      /* free list */
-       Avlnode         *c_idtree;
+       Avlnode         *c_idtree;
        EntryInfo       *c_lruhead;     /* lru - add accessed entries here */
        EntryInfo       *c_lrutail;     /* lru - rem lru entries from here */
+       EntryInfo       c_dntree;
+       int             c_maxsize;
+       int             c_cursize;
+       int             c_minfree;
+       int             c_eiused;       /* EntryInfo's in use */
+       int             c_leaves;       /* EntryInfo leaf nodes */
        ldap_pvt_thread_rdwr_t c_rwlock;
-       ldap_pvt_thread_mutex_t lru_mutex;
-       u_int32_t       c_locker;       /* used by lru cleaner */
+       ldap_pvt_thread_mutex_t lru_head_mutex;
+       ldap_pvt_thread_mutex_t lru_tail_mutex;
+       ldap_pvt_thread_mutex_t c_count_mutex;
+       ldap_pvt_thread_mutex_t c_eifree_mutex;
 #ifdef SLAP_ZONE_ALLOC
        void *c_zctx;
 #endif
@@ -148,6 +152,16 @@ struct bdb_db_info {
        DB                      *bdi_db;
 };
 
+typedef struct bdb_monitor_t {
+       void            *bdm_cb;
+       struct berval   bdm_nbase;
+       int             bdm_scope;
+       struct berval   bdm_filter;
+} bdb_monitor_t;
+
+/* From ldap_rq.h */
+struct re_s;
+
 struct bdb_info {
        DB_ENV          *bi_dbenv;
 
@@ -173,8 +187,8 @@ struct bdb_info {
        int                     bi_txn_cp;
        u_int32_t       bi_txn_cp_min;
        u_int32_t       bi_txn_cp_kbyte;
-       void            *bi_txn_cp_task;
-       void            *bi_index_task;
+       struct re_s             *bi_txn_cp_task;
+       struct re_s             *bi_index_task;
 
        int                     bi_lock_detect;
        long            bi_shm_key;
@@ -191,6 +205,7 @@ struct bdb_info {
        alock_info_t    bi_alock_info;
        char            *bi_db_config_path;
        BerVarray       bi_db_config;
+       bdb_monitor_t   bi_monitor;
        int             bi_flags;
 #define        BDB_IS_OPEN             0x01
 #define        BDB_HAS_CONFIG  0x02
@@ -258,6 +273,10 @@ struct bdb_op_info {
 
 #endif
 
+#ifndef DB_BUFFER_SMALL
+#define DB_BUFFER_SMALL                        ENOMEM
+#endif
+
 #define BDB_REUSE_LOCKERS
 
 #define BDB_CSN_COMMIT 0