]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/back-ldbm.h
ITS#4310 seems to affect also back-ldbm
[openldap] / servers / slapd / back-ldbm / back-ldbm.h
index efb524cda5073a2cfdb54d23be138f0fdecd96ee..a7937513925c09e498e1e798c307b9a7286e3195 100644 (file)
@@ -1,14 +1,24 @@
 /* back-ldbm.h - ldap ldbm back-end header file */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2000 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-2006 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>.
  */
 
 #ifndef _BACK_LDBM_H_
 #define _BACK_LDBM_H_
 
 #include "ldbm.h"
+#include "alock.h"
 
 LDAP_BEGIN_DECL
 
@@ -20,11 +30,6 @@ LDAP_BEGIN_DECL
 #      define DEFAULT_DBCACHE_SIZE 100000
 #endif
 
-#define DEFAULT_DB_DIRECTORY   LDAP_RUNDIR LDAP_DIRSEP "openldap-ldbm"
-#define DEFAULT_MODE           0600
-
-#define SUBLEN                 3
-
 #define DN_BASE_PREFIX         SLAP_INDEX_EQUALITY_PREFIX
 #define DN_ONE_PREFIX          '%'
 #define DN_SUBTREE_PREFIX      '@'
@@ -63,6 +68,11 @@ typedef ID ID_BLOCK;
 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
 
 #define ID_BLOCK_NMAX(b)               ((b)[ID_BLOCK_NMAX_OFFSET])
+
+/* Use this macro to get the value, but not to set it.
+ * By default this is identical to above.
+ */
+#define        ID_BLOCK_NMAXN(b)               ID_BLOCK_NMAX(b)
 #define ID_BLOCK_NIDS(b)               ((b)[ID_BLOCK_NIDS_OFFSET])
 #define ID_BLOCK_ID(b, n)              ((b)[ID_BLOCK_IDS_OFFSET+(n)])
 
@@ -74,6 +84,23 @@ typedef ID ID_BLOCK;
 #define ID_BLOCK_INDIRECT_VALUE        0
 #define ID_BLOCK_INDIRECT(b)   (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
 
+#define        USE_INDIRECT_NIDS       1
+
+#ifdef USE_INDIRECT_NIDS
+/*
+ * Use the high bit of ID_BLOCK_NMAX to indicate an INDIRECT block, thus
+ * freeing up the ID_BLOCK_NIDS to store an actual count. This allows us
+ * to use binary search on INDIRECT blocks.
+ */
+#undef ID_BLOCK_NMAXN
+#define        ID_BLOCK_NMAXN(b)               ((b)[ID_BLOCK_NMAX_OFFSET]&0x7fffffff)
+#undef ID_BLOCK_INDIRECT_VALUE
+#define        ID_BLOCK_INDIRECT_VALUE 0x80000000
+#undef ID_BLOCK_INDIRECT
+#define        ID_BLOCK_INDIRECT(b)    (ID_BLOCK_NMAX(b) & ID_BLOCK_INDIRECT_VALUE)
+
+#endif /* USE_INDIRECT_NIDS */
+
 /* for the in-core cache of entries */
 typedef struct ldbm_cache {
        int             c_maxsize;
@@ -93,21 +120,22 @@ typedef struct ldbm_dbcache {
        int             dbc_refcnt;
        int             dbc_maxids;
        int             dbc_maxindirect;
+       int             dbc_dirty;
+       int             dbc_flags;
        time_t  dbc_lastref;
        long    dbc_blksize;
        char    *dbc_name;
        LDBM    dbc_db;
+       ldap_pvt_thread_mutex_t dbc_write_mutex;
 } DBCache;
 
 #define MAXDBCACHE     128
 
 struct ldbminfo {
+       ldap_pvt_thread_rdwr_t          li_giant_rwlock;
        ID                      li_nextid;
-       ldap_pvt_thread_mutex_t         li_nextid_mutex;
-       ldap_pvt_thread_mutex_t         li_root_mutex;
-       ldap_pvt_thread_mutex_t         li_add_mutex;
        int                     li_mode;
-       slap_index      li_defaultmask;
+       slap_mask_t     li_defaultmask;
        char                    *li_directory;
        Cache           li_cache;
        Avlnode                 *li_attrs;
@@ -117,6 +145,13 @@ struct ldbminfo {
        DBCache         li_dbcache[MAXDBCACHE];
        ldap_pvt_thread_mutex_t         li_dbcache_mutex;
        ldap_pvt_thread_cond_t          li_dbcache_cv;
+       DB_ENV                  *li_dbenv;
+       int                     li_envdirok;
+       int                     li_dbsyncfreq;
+       int                     li_dbsyncwaitn;
+       int                     li_dbsyncwaitinterval;
+       int                     li_dbsyncwaitcount;
+       alock_info_t    li_alock_info;
 };
 
 LDAP_END_DECL