]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
Experiment with busy loop protection...
[openldap] / servers / slapd / back-monitor / back-monitor.h
1 /* back-monitor.h - ldap monitor back-end header file */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
8  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9  * 
10  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
11  * 
12  * This work has beed deveolped for the OpenLDAP Foundation 
13  * in the hope that it may be useful to the Open Source community, 
14  * but WITHOUT ANY WARRANTY.
15  * 
16  * Permission is granted to anyone to use this software for any purpose
17  * on any computer system, and to alter it and redistribute it, subject
18  * to the following restrictions:
19  * 
20  * 1. The author and SysNet s.n.c. are not responsible for the consequences
21  *    of use of this software, no matter how awful, even if they arise from
22  *    flaws in it.
23  * 
24  * 2. The origin of this software must not be misrepresented, either by
25  *    explicit claim or by omission.  Since few users ever read sources,
26  *    credits should appear in the documentation.
27  * 
28  * 3. Altered versions must be plainly marked as such, and must not be
29  *    misrepresented as being the original software.  Since few users
30  *    ever read sources, credits should appear in the documentation.
31  *    SysNet s.n.c. cannot be responsible for the consequences of the
32  *    alterations.
33  * 
34  * 4. This notice may not be removed or altered.
35  */
36
37 #ifndef _BACK_MONITOR_H_
38 #define _BACK_MONITOR_H_
39
40 #include <slap.h>
41 #include <avl.h>
42 #include <ldap_pvt.h>
43 #include <ldap_pvt_thread.h>
44
45 LDAP_BEGIN_DECL
46
47 /*
48  * The cache maps DNs to Entries.
49  * Each entry, on turn, holds the list of its children in the e_private field.
50  * This is used by search operation to perform onelevel and subtree candidate
51  * selection.
52  */
53 struct monitorcache {
54         char                    *mc_ndn;
55         Entry                   *mc_e;
56 };
57
58 struct monitorentrypriv {
59         ldap_pvt_thread_mutex_t mp_mutex;       /* entry mutex */
60         Entry                   *mp_next;       /* pointer to next sibling */
61         Entry                   *mp_children;   /* pointer to first child */
62         struct monitorsubsys    *mp_info;       /* subsystem info */
63 #define mp_type         mp_info->mss_type
64         int                     mp_flags;       /* flags */
65
66 #define MONITOR_F_NONE          0x00
67 #define MONITOR_F_SUB           0x01            /* subentry of subsystem */
68 #define MONITOR_F_PERSISTENT    0x10            /* persistent entry */
69 #define MONITOR_F_PERSISTENT_CH 0x20            /* subsystem generates 
70                                                    persistent entries */
71 #define MONITOR_F_VOLATILE      0x40            /* volatile entry */
72 #define MONITOR_F_VOLATILE_CH   0x80            /* subsystem generates 
73                                                    volatile entries */
74 };
75
76 struct monitorinfo {
77         Avlnode                 *mi_cache;
78         ldap_pvt_thread_mutex_t mi_cache_mutex;
79 };
80
81 /*
82  * DNs
83  */
84 #define SLAPD_MONITOR_LISTENER          0
85 #define SLAPD_MONITOR_LISTENER_NAME     "Listener"
86 #define SLAPD_MONITOR_LISTENER_RDN      \
87         "cn=" SLAPD_MONITOR_LISTENER_NAME
88 #define SLAPD_MONITOR_LISTENER_DN       \
89         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
90
91 #define SLAPD_MONITOR_DATABASE          1
92 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
93 #define SLAPD_MONITOR_DATABASE_RDN      \
94         "cn=" SLAPD_MONITOR_DATABASE_NAME
95 #define SLAPD_MONITOR_DATABASE_DN       \
96         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
97
98 #define SLAPD_MONITOR_BACKEND           2
99 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
100 #define SLAPD_MONITOR_BACKEND_RDN       \
101         "cn=" SLAPD_MONITOR_BACKEND_NAME
102 #define SLAPD_MONITOR_BACKEND_DN        \
103         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
104
105 #define SLAPD_MONITOR_THREAD            3
106 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
107 #define SLAPD_MONITOR_THREAD_RDN        \
108         "cn=" SLAPD_MONITOR_THREAD_NAME
109 #define SLAPD_MONITOR_THREAD_DN \
110         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
111
112 #define SLAPD_MONITOR_SASL              4
113 #define SLAPD_MONITOR_SASL_NAME         "SASL"
114 #define SLAPD_MONITOR_SASL_RDN  \
115         "cn=" SLAPD_MONITOR_SASL_NAME
116 #define SLAPD_MONITOR_SASL_DN   \
117         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
118
119 #define SLAPD_MONITOR_TLS               5
120 #define SLAPD_MONITOR_TLS_NAME          "TLS"
121 #define SLAPD_MONITOR_TLS_RDN   \
122         "cn=" SLAPD_MONITOR_TLS_NAME
123 #define SLAPD_MONITOR_TLS_DN    \
124         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
125
126 #define SLAPD_MONITOR_CONN              6
127 #define SLAPD_MONITOR_CONN_NAME         "Connections"
128 #define SLAPD_MONITOR_CONN_RDN  \
129         "cn=" SLAPD_MONITOR_CONN_NAME
130 #define SLAPD_MONITOR_CONN_DN   \
131         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
132
133 #define SLAPD_MONITOR_READW             7
134 #define SLAPD_MONITOR_READW_NAME        "Read Waiters"
135 #define SLAPD_MONITOR_READW_RDN \
136         "cn=" SLAPD_MONITOR_READW_NAME
137 #define SLAPD_MONITOR_READW_DN  \
138         SLAPD_MONITOR_READW_RDN "," SLAPD_MONITOR_DN
139
140 #define SLAPD_MONITOR_WRITEW            8
141 #define SLAPD_MONITOR_WRITEW_NAME       "Write Waiters"
142 #define SLAPD_MONITOR_WRITEW_RDN        \
143         "cn=" SLAPD_MONITOR_WRITEW_NAME
144 #define SLAPD_MONITOR_WRITEW_DN \
145         SLAPD_MONITOR_WRITEW_RDN "," SLAPD_MONITOR_DN
146
147 struct monitorsubsys {
148         int             mss_type;
149         char            *mss_name;
150         char            *mss_rdn;
151         char            *mss_dn;
152         char            *mss_ndn;
153         int             mss_flags;
154
155 #define MONITOR_HAS_VOLATILE_CH( mp ) \
156         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
157
158         int             ( *mss_init )( BackendDB * );
159         int             ( *mss_update )( struct monitorinfo *, Entry * );
160         int             ( *mss_create )( struct monitorinfo *, const char *ndn, Entry *, Entry ** );
161 };
162
163 extern struct monitorsubsys monitor_subsys[];
164
165 extern AttributeDescription *monitor_ad_desc;
166
167 /*
168  * cache
169  */
170
171 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
172 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
173 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
174 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep ));
175 extern int monitor_cache_dn2entry LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep ));
176 extern int monitor_cache_lock LDAP_P(( Entry *e ));
177 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
178
179 /*
180  * update
181  */
182
183 extern int monitor_entry_update LDAP_P(( struct monitorinfo *mi, Entry *e ));
184 extern int monitor_entry_create LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry *e_parent, Entry **ep ));
185
186 LDAP_END_DECL
187
188 #include "proto-back-monitor.h"
189
190 #endif /* _back_monitor_h_ */
191