]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slap.h
Vienna Bulk Commit
[openldap] / servers / slapd / slap.h
index 17f67a30a5840ee83bc035e328e603374b763be1..5b231775b1e1184cadab18493d300844dbe84fd1 100644 (file)
@@ -5,16 +5,10 @@
 
 #include <stdlib.h>
 
-#ifndef LDAP_SYSLOG
-#define LDAP_SYSLOG 1
-#endif
-
 #include <sys/types.h>
 #include <ac/syslog.h>
 #include <ac/regex.h>
-
-#undef NDEBUG
-#include <assert.h>
+#include <ac/socket.h>                 /* needed by LDAP_CONNECTIONLESS */
 
 #include "avl.h"
 
 #define ldap_debug slap_debug
 #endif
 
-#ifdef SLAPD_BDB2
-extern int bdb2i_do_timing;
-#endif
-
 
 #include "ldap_log.h"
 
-#include "../../libraries/liblber/lber-int.h"
+#include "lber.h"
 #include "ldap.h"
 
 #include "ldap_pvt_thread.h"
@@ -138,33 +128,19 @@ typedef unsigned long     ID;
  * represents an entry in core
  */
 typedef struct entry {
-       ldap_pvt_thread_rdwr_t  e_rdwr; /* reader/writer lock */
-
-       char            *e_dn;          /* DN of this entry               */
-       char            *e_ndn;         /* normalized DN of this entry    */
-       Attribute       *e_attrs;       /* list of attributes + values    */
-
-
        /*
         * The ID field should only be changed before entry is
         * inserted into a cache.  The ID value is backend
         * specific.
         */
-       ID              e_id;           /* id of this entry - this should */
-                                       /* really be private to back-ldbm */
+       ID              e_id;
 
-       /*
-        * remaining fields require backend cache lock to access
-        * These items are specific to the LDBM backend and should
-        * be hidden.
-        */
-       char            e_state;        /* for the cache                  */
-#define ENTRY_STATE_DELETED            1
-#define ENTRY_STATE_CREATING   2
+       char            *e_dn;          /* DN of this entry */
+       char            *e_ndn;         /* normalized DN of this entry */
+       Attribute       *e_attrs;       /* list of attributes + values */
 
-       int             e_refcnt;       /* # threads ref'ing this entry   */
-       struct entry    *e_lrunext;     /* for cache lru list             */
-       struct entry    *e_lruprev;
+       /* for use by the backend for any purpose */
+       void*   e_private;
 } Entry;
 
 /*
@@ -248,6 +224,10 @@ extern int                 slapMode;
 #define SLAP_UNDEFINED_MODE    0
 #define SLAP_SERVER_MODE       1
 #define SLAP_TOOL_MODE         2
+#ifdef SLAPD_BDB2
+#  define SLAP_TIMEDSERVER_MODE  3
+#  define SLAP_TOOLID_MODE       4
+#endif
 
 /* temporary aliases */
 typedef BackendDB Backend;
@@ -270,6 +250,7 @@ struct backend_db {
 #define                be_modrdn       bd_info->bi_op_modrdn
 #define                be_search       bd_info->bi_op_search
 
+#define                be_release      bd_info->bi_entry_release_rw
 #define                be_group        bd_info->bi_acl_group
 
        /* these should be renamed from be_ to bd_ */
@@ -368,7 +349,8 @@ struct backend_info {
                char *dn, LDAPModList *m));
        int     (*bi_op_modrdn) LDAP_P((BackendDB *bd,
                struct slap_conn *c, struct slap_op *o,
-               char *dn, char *newrdn, int deleteoldrdn ));
+               char *dn, char *newrdn, int deleteoldrdn,
+               char *newSuperior));
        int     (*bi_op_add)    LDAP_P((BackendDB *bd,
                struct slap_conn *c, struct slap_op *o,
                Entry *e));
@@ -381,12 +363,14 @@ struct backend_info {
                int msgid));
 
        /* Auxilary Functions */
+       int     (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
 #ifdef SLAPD_ACLGROUPS
        int     (*bi_acl_group)  LDAP_P((Backend *bd,
                Entry *e, char *bdn, char *edn,
                char *objectclassValue, char *groupattrName ));
 #endif
 
+       unsigned int bi_nDB;    /* number of databases of this type */
        void    *bi_private;    /* anything the backend type needs */
 };
 
@@ -395,27 +379,33 @@ struct backend_info {
  */
 
 typedef struct slap_op {
+       long    o_opid;         /* id of this operation           */
+       long    o_msgid;        /* msgid of the request           */
+
+       ldap_pvt_thread_t       o_tid;          /* thread handling this op        */
+
        BerElement      *o_ber;         /* ber of the request             */
-       long            o_msgid;        /* msgid of the request           */
+
        unsigned long   o_tag;          /* tag of the request             */
        time_t          o_time;         /* time op was initiated          */
        char            *o_dn;          /* dn bound when op was initiated */
        char            *o_ndn;         /* normalized dn bound when op was initiated */
-       int             o_authtype;     /* auth method used to bind dn    */
+       int                     o_authtype;     /* auth method used to bind dn    */
                                        /* values taken from ldap.h       */
                                        /* LDAP_AUTH_*                    */
-       int             o_opid;         /* id of this operation           */
-       int             o_connid;       /* id of conn initiating this op  */
+
+/*      long   o_connid;       *//* id of conn initiating this op  */
+
 #ifdef LDAP_CONNECTIONLESS
        int             o_cldap;        /* != 0 if this came in via CLDAP */
        struct sockaddr o_clientaddr;   /* client address if via CLDAP    */
        char            o_searchbase;   /* search base if via CLDAP       */
 #endif
-       struct slap_op  *o_next;        /* next operation pending         */
-       ldap_pvt_thread_t       o_tid;          /* thread handling this op        */
-       int             o_abandon;      /* signals op has been abandoned  */
-       ldap_pvt_thread_mutex_t o_abandonmutex; /* signals op has been abandoned  */
 
+       ldap_pvt_thread_mutex_t o_abandonmutex; /* protects o_abandon  */
+       int             o_abandon;      /* abandon flag */
+
+       struct slap_op  *o_next;        /* next operation in list         */
        void    *o_private;     /* anything the backend needs     */
 } Operation;
 
@@ -424,40 +414,51 @@ typedef struct slap_op {
  */
 
 typedef struct slap_conn {
-       Sockbuf         c_sb;           /* ber connection stuff           */
-       char            *c_cdn;         /* DN provided by the client */
-       char            *c_dn;          /* DN bound to this conn  */
-       ldap_pvt_thread_mutex_t c_dnmutex;      /* mutex for c_dn field           */
+       int                     c_struct_state; /* structure management state */
+       int                     c_conn_state;   /* connection state */
+
+       ldap_pvt_thread_mutex_t c_mutex; /* protect the connection */
+       Sockbuf         *c_sb;                  /* ber connection stuff           */
+
+       /* only can be changed by connect_init */
+       time_t          c_starttime;    /* when the connection was opened */
+       long            c_connid;       /* id of this connection for stats*/
+       char            *c_client_addr; /* address of client */
+       char            *c_client_name; /* name of client */
+
+       /* only can be changed by binding thread */
+       char    *c_cdn;         /* DN provided by the client */
+       char    *c_dn;          /* DN bound to this conn  */
        int             c_protocol;     /* version of the LDAP protocol used by client */
        int             c_authtype;     /* auth method used to bind c_dn  */
 #ifdef LDAP_COMPAT
        int             c_version;      /* for compatibility w/2.0, 3.0   */
 #endif
-       char            *c_addr;        /* address of client on this conn */
-       char            *c_domain;      /* domain of client on this conn  */
-       Operation       *c_ops;         /* list of pending operations     */
-       ldap_pvt_thread_mutex_t c_opsmutex;     /* mutex for c_ops list & stats   */
-       ldap_pvt_thread_mutex_t c_pdumutex;     /* only one pdu written at a time */
-       ldap_pvt_thread_cond_t  c_wcv;          /* used to wait for sd write-ready*/
-       int             c_gettingber;   /* in the middle of ber_get_next  */
-       BerElement      *c_currentber;  /* ber we're getting              */
-       int             c_writewaiter;  /* signals write-ready sd waiter  */
-       int             c_pduwaiters;   /* signals threads waiting 4 pdu  */
-       time_t          c_starttime;    /* when the connection was opened */
-       int             c_connid;       /* id of this connection for stats*/
-       int             c_opsinitiated; /* # ops initiated/next op id     */
-       int             c_opscompleted; /* # ops completed                */
+
+       Operation       *c_ops;                 /* list of operations being processed */
+       Operation       *c_pending_ops; /* list of pending operations */
+
+       ldap_pvt_thread_mutex_t c_write_mutex;  /* only one pdu written at a time */
+       ldap_pvt_thread_cond_t  c_write_cv;             /* used to wait for sd write-ready*/
+
+       BerElement      *c_currentber;  /* ber we're attempting to read */
+       int             c_writewaiter;  /* true if writer is waiting */
+
+       long    c_n_ops_received;               /* num of ops received (next op_id) */
+       long    c_n_ops_executing;      /* num of ops currently executing */
+       long    c_n_ops_pending;                /* num of ops pending execution */
+       long    c_n_ops_completed;      /* num of ops completed */
 } Connection;
 
 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
-       { \
-               if ( ldap_debug & level ) \
-                       fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
-               if ( ldap_syslog & level ) \
-                       syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
-                           arg2, arg3 ); \
-       }
+       do { \
+               if ( ldap_debug & (level) ) \
+                       fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\
+               if ( ldap_syslog & (level) ) \
+                       syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \
+                               (arg2), (arg3) ); \
+       } while (0)
 #else
 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
 #endif