The suffix "cn=Monitor" is implicitly activated (it cannot be given
as a suffix of the database as usually done for conventional backends).
Note that the "cn=Monitor" naming context appears in the rootDSE
-(FIXME: do we really want this?)
+in the attribute monitorContext
A bind operation is provided; at present it allows to bind as the
backend rootdn. As a result, the backend supports the rootdn/rootpw
The subsystems are:
- Listener
- Databases
Backends
- Threads
- SASL
- TLS
Connections
- Read Waiters
- Write Waiters
+ Databases
+ Listener
Log
Operations
+ Overlays
+ SASL
Statistics
+ Threads
Time
-
-
-
-LISTENER SUBSYSTEM
-
-It contains the description of the devices the server is currently
-listening on
-
-
-
-DATABASES SUBSYSTEM
-
-The main entry contains the naming context of each configured database;
-the subentries contain, for each database, the type and the naming
-context.
+ TLS
+ Read/Write Waiters
-THREADS SUBSYSTEM
-
-It contains the maximum number of threads enabled at startup and the
-current backload.
-
-
-
-SASL
-
-Currently empty.
-
-
-
-TLS
-
-Currently empty.
-
-
-
CONNECTIONS
The main entry is empty; it should contain some statistics on the number
-READ WAITERS SUBSYSTEM
+DATABASES SUBSYSTEM
-It contains the number of current read waiters.
+The main entry contains the naming context of each configured database;
+the subentries contain, for each database, the type and the naming
+context.
-WRITE WAITERS SUBSYSTEM
+LISTENER SUBSYSTEM
-It contains the number of current write waiters.
+It contains the description of the devices the server is currently
+listening on
Initiated
Completed
+and for each operation type, i.e.:
+
+ Bind
+ Unbind
+ Add
+ Delete
+ Modrdn
+ Modify
+ Compare
+ Search
+ Abandon
+ Extended
+
+
+
+OVERLAYS SUBSYSTEM
+
+The main entry contains the type of overlays available at run-time;
+the subentries, for each overlay, contain the type of the overlay.
+It should also contain the modules that have been loaded if dynamic
+overlays are enabled.
+
+
+
+SASL
+
+Currently empty.
+
-SENT SUBSYSTEM
+STATISTICS SUBSYSTEM
It shows some statistics on the data sent by the server:
Bytes
PDU
- Referrals
Entries
+ Referrals
+
+
+
+THREADS SUBSYSTEM
+
+It contains the maximum number of threads enabled at startup and the
+current backload.
+TLS
+
+Currently empty.
+
+
+
+READ/WRITE WAITERS SUBSYSTEM
+
+It contains the number of current read waiters.
+
+
+
NOTES
This document is in a very early stage of maturity and will
* DNs
*/
-#define SLAPD_MONITOR_AT "cn"
-
-#define SLAPD_MONITOR_LISTENER 0
-#define SLAPD_MONITOR_LISTENER_NAME "Listeners"
-#define SLAPD_MONITOR_LISTENER_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
-#define SLAPD_MONITOR_LISTENER_DN \
- SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
+enum {
+ SLAPD_MONITOR_BACKEND = 0,
+ SLAPD_MONITOR_CONN,
+ SLAPD_MONITOR_DATABASE,
+ SLAPD_MONITOR_LISTENER,
+ SLAPD_MONITOR_LOG,
+ SLAPD_MONITOR_OPS,
+ SLAPD_MONITOR_OVERLAY,
+ SLAPD_MONITOR_SASL,
+ SLAPD_MONITOR_SENT,
+ SLAPD_MONITOR_THREAD,
+ SLAPD_MONITOR_TIME,
+ SLAPD_MONITOR_TLS,
+ SLAPD_MONITOR_RWW,
+
+ SLAPD_MONITOR_LAST
+};
-#define SLAPD_MONITOR_DATABASE 1
-#define SLAPD_MONITOR_DATABASE_NAME "Databases"
-#define SLAPD_MONITOR_DATABASE_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
-#define SLAPD_MONITOR_DATABASE_DN \
- SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
+#define SLAPD_MONITOR_AT "cn"
-#define SLAPD_MONITOR_BACKEND 2
#define SLAPD_MONITOR_BACKEND_NAME "Backends"
#define SLAPD_MONITOR_BACKEND_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
#define SLAPD_MONITOR_BACKEND_DN \
SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_THREAD 3
-#define SLAPD_MONITOR_THREAD_NAME "Threads"
-#define SLAPD_MONITOR_THREAD_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
-#define SLAPD_MONITOR_THREAD_DN \
- SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
-
-#define SLAPD_MONITOR_SASL 4
-#define SLAPD_MONITOR_SASL_NAME "SASL"
-#define SLAPD_MONITOR_SASL_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
-#define SLAPD_MONITOR_SASL_DN \
- SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
-
-#define SLAPD_MONITOR_TLS 5
-#define SLAPD_MONITOR_TLS_NAME "TLS"
-#define SLAPD_MONITOR_TLS_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
-#define SLAPD_MONITOR_TLS_DN \
- SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
-
-#define SLAPD_MONITOR_CONN 6
#define SLAPD_MONITOR_CONN_NAME "Connections"
#define SLAPD_MONITOR_CONN_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
#define SLAPD_MONITOR_CONN_DN \
SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_RWW 7
-#define SLAPD_MONITOR_RWW_NAME "Waiters"
-#define SLAPD_MONITOR_RWW_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
-#define SLAPD_MONITOR_RWW_DN \
- SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
+#define SLAPD_MONITOR_DATABASE_NAME "Databases"
+#define SLAPD_MONITOR_DATABASE_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
+#define SLAPD_MONITOR_DATABASE_DN \
+ SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
+
+#define SLAPD_MONITOR_LISTENER_NAME "Listeners"
+#define SLAPD_MONITOR_LISTENER_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
+#define SLAPD_MONITOR_LISTENER_DN \
+ SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_LOG 8
#define SLAPD_MONITOR_LOG_NAME "Log"
#define SLAPD_MONITOR_LOG_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
#define SLAPD_MONITOR_LOG_DN \
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_OPS 9
#define SLAPD_MONITOR_OPS_NAME "Operations"
#define SLAPD_MONITOR_OPS_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
#define SLAPD_MONITOR_OPS_DN \
SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_SENT 10
+#define SLAPD_MONITOR_OVERLAY_NAME "Overlay"
+#define SLAPD_MONITOR_OVERLAY_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
+#define SLAPD_MONITOR_OVERLAY_DN \
+ SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
+
+#define SLAPD_MONITOR_SASL_NAME "SASL"
+#define SLAPD_MONITOR_SASL_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
+#define SLAPD_MONITOR_SASL_DN \
+ SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
+
#define SLAPD_MONITOR_SENT_NAME "Statistics"
#define SLAPD_MONITOR_SENT_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
#define SLAPD_MONITOR_SENT_DN \
SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_TIME 11
+#define SLAPD_MONITOR_THREAD_NAME "Threads"
+#define SLAPD_MONITOR_THREAD_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
+#define SLAPD_MONITOR_THREAD_DN \
+ SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
+
#define SLAPD_MONITOR_TIME_NAME "Time"
#define SLAPD_MONITOR_TIME_RDN \
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
#define SLAPD_MONITOR_TIME_DN \
SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
-#define SLAPD_MONITOR_OVERLAY 12
-#define SLAPD_MONITOR_OVERLAY_NAME "Overlay"
-#define SLAPD_MONITOR_OVERLAY_RDN \
- SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
-#define SLAPD_MONITOR_OVERLAY_DN \
- SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
+#define SLAPD_MONITOR_TLS_NAME "TLS"
+#define SLAPD_MONITOR_TLS_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
+#define SLAPD_MONITOR_TLS_DN \
+ SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
+
+#define SLAPD_MONITOR_RWW_NAME "Waiters"
+#define SLAPD_MONITOR_RWW_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
+#define SLAPD_MONITOR_RWW_DN \
+ SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
struct monitorsubsys {
- int mss_type;
char *mss_name;
struct berval mss_rdn;
struct berval mss_dn;
)
{
struct monitorinfo *mi;
- Entry *e, *e_backend, *e_tmp;
+ Entry *e_backend, **ep;
int i;
struct monitorentrypriv *mp;
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn,
- &e_backend ) ) {
+ &e_backend ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
- for ( i = nBackendInfo; i--; ) {
+ mp = ( struct monitorentrypriv * )e_backend->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
+
+ for ( i = 0; i < nBackendInfo; i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
BackendInfo *bi;
struct berval bv;
int j;
+ Entry *e;
bi = &backendInfo[i];
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
- "unable to create entry 'cn=Backend %d,%s'\n%s",
- i,
- monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
- "" );
+ "unable to create entry \"cn=Backend %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_BACKEND];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_BACKEND].mss_flags
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_backend_init: "
- "unable to add entry 'cn=Backend %d,%s'\n%s",
+ "unable to add entry \"cn=Backend %d,%s\"\n",
i,
- monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val,
- "" );
+ monitor_subsys[SLAPD_MONITOR_BACKEND].mss_ndn.bv_val, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- mp = ( struct monitorentrypriv * )e_backend->e_private;
- mp->mp_children = e_tmp;
-
monitor_cache_release( mi, e_backend );
return( 0 );
#include "portable.h"
#include <stdio.h>
+#include "ac/string.h"
#include "slap.h"
{
struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
int rc;
- struct berval p_ndn = { 0L, NULL };
+ struct berval p_ndn = BER_BVNULL;
Entry *e_parent;
struct monitorentrypriv *mp;
}
/* try with parent/ancestors */
- if ( ndn->bv_len ) {
- dnParent( ndn, &p_ndn );
- }
+ if ( BER_BVISNULL( ndn ) ) {
+ BER_BVSTR( &p_ndn, "" );
- if ( p_ndn.bv_val == NULL ) {
- p_ndn.bv_val = "";
- p_ndn.bv_len = 0;
-
} else {
- p_ndn.bv_len = ndn->bv_len
- - ( ber_len_t ) ( p_ndn.bv_val - ndn->bv_val );
+ dnParent( ndn, &p_ndn );
}
rc = monitor_cache_dn2entry( op, &p_ndn, &e_parent, matched );
- if ( rc || e_parent == NULL) {
+ if ( rc || e_parent == NULL ) {
return( -1 );
}
#include "lutil.h"
#include "back-monitor.h"
-#define CONN_CN_PREFIX "Connection"
-
int
monitor_subsys_conn_init(
BackendDB *be
{
struct monitorinfo *mi;
- Entry *e, *e_tmp, *e_conn;
+ Entry *e, **ep, *e_conn;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
struct berval bv;
mi = ( struct monitorinfo * )be->be_private;
if ( monitor_cache_get( mi,
- &monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) ) {
+ &monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_conn->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
/*
* Total conns
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
- "unable to create entry 'cn=Total,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
- "", "" );
+ "unable to create entry \"cn=Total,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- bv.bv_val = "0";
- bv.bv_len = 1;
+ BER_BVSTR( &bv, "0" );
attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
- "unable to add entry 'cn=Total,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
- "", "" );
+ "unable to add entry \"cn=Total,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
-
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
+
/*
* Current conns
*/
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
- "unable to create entry 'cn=Current,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
- "", "" );
+ "unable to create entry \"cn=Current,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- bv.bv_val = "0";
- bv.bv_len = 1;
+ BER_BVSTR( &bv, "0" );
attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_CONN];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_CONN].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_init: "
- "unable to add entry 'cn=Current,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val,
- "", "" );
+ "unable to add entry \"cn=Current,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = e;
-
- mp = ( struct monitorentrypriv * )e_conn->e_private;
- mp->mp_children = e_tmp;
+ *ep = e;
+ ep = &mp->mp_next;
monitor_cache_release( mi, e_conn );
Entry *e
)
{
- struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
- long n = -1;
+ struct monitorinfo *mi =
+ (struct monitorinfo *)op->o_bd->be_private;
+
+ long n = -1;
+ static struct berval total_bv = BER_BVC( "cn=total" ),
+ current_bv = BER_BVC( "cn=current" );
+ struct berval rdn;
assert( mi );
assert( e );
+
+ dnRdn( &e->e_nname, &rdn );
- if ( strncasecmp( e->e_ndn, "cn=total",
- sizeof("cn=total")-1 ) == 0 ) {
+ if ( dn_match( &rdn, &total_bv ) ) {
n = connections_nextid();
- } else if ( strncasecmp( e->e_ndn, "cn=current",
- sizeof("cn=current")-1 ) == 0 ) {
+ } else if ( dn_match( &rdn, ¤t_bv ) ) {
Connection *c;
int connindex;
n++, c = connection_next( c, &connindex ) ) {
/* No Op */ ;
}
- connection_done(c);
+ connection_done( c );
}
if ( n != -1 ) {
Attribute *a;
char buf[] = "+9223372036854775807L";
+ ber_len_t len;
a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
if ( a == NULL ) {
}
snprintf( buf, sizeof( buf ), "%ld", n );
- free( a->a_vals[ 0 ].bv_val );
- ber_str2bv( buf, 0, 1, a->a_vals );
+ len = strlen( buf );
+ if ( len > a->a_vals[ 0 ].bv_len ) {
+ a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 );
+ }
+ a->a_vals[ 0 ].bv_len = len;
+ AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
}
return( 0 );
#endif
snprintf( buf, sizeof( buf ),
- "dn: cn=" CONN_CN_PREFIX " %ld,%s\n"
+ "dn: cn=Connection %ld,%s\n"
"objectClass: %s\n"
"structuralObjectClass: %s\n"
- "cn: " CONN_CN_PREFIX " %ld\n"
+ "cn: Connection %ld\n"
"creatorsName: %s\n"
"modifiersName: %s\n"
"createTimestamp: %s\n"
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_conn_create: "
"unable to create entry "
- "'cn=" CONN_CN_PREFIX " %ld,%s' entry\n",
+ "\"cn=Connection %ld,%s\" entry\n",
c->c_connid,
monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val, 0 );
return( -1 );
/* monitored info */
sprintf( buf,
- "%ld : %ld "
+ "%ld "
+ ": %ld "
": %ld/%ld/%ld/%ld "
": %ld/%ld/%ld "
": %s%s%s%s%s%s "
- ": %s : %s : %s "
- ": %s : %s : %s : %s",
+ ": %s "
+ ": %s "
+ ": %s "
+ ": %s "
+ ": %s "
+ ": %s "
+ ": %s",
c->c_connid,
(long) c->c_protocol,
c->c_n_ops_received, c->c_n_ops_executing,
- c->c_n_ops_pending, c->c_n_ops_completed,
+ c->c_n_ops_pending, c->c_n_ops_completed,
/* add low-level counters here */
c->c_n_get, c->c_n_read, c->c_n_write,
Entry **ep
)
{
- struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
+ struct monitorinfo *mi =
+ (struct monitorinfo *)op->o_bd->be_private;
+
Connection *c;
int connindex;
struct monitorentrypriv *mp;
+ int rc = 0;
assert( mi != NULL );
assert( e_parent != NULL );
*ep = NULL;
if ( ndn == NULL ) {
- Entry *e, *e_tmp = NULL;
+ Entry *e = NULL,
+ *e_tmp = NULL;
/* create all the children of e_parent */
for ( c = connection_first( &connindex );
c != NULL;
c = connection_next( c, &connindex )) {
if ( conn_create( mi, c, &e ) || e == NULL ) {
- connection_done(c);
for ( ; e_tmp != NULL; ) {
mp = ( struct monitorentrypriv * )e_tmp->e_private;
e = mp->mp_next;
e_tmp = e;
}
- return( -1 );
+ rc = -1;
+ break;
}
mp = ( struct monitorentrypriv * )e->e_private;
mp->mp_next = e_tmp;
e_tmp = e;
}
connection_done(c);
-
*ep = e;
} else {
- LDAPRDN values = NULL;
- const char *text = NULL;
- unsigned long connid;
-
- /* create exactly the required entry */
+ unsigned long connid;
+ char *next = NULL;
+ static struct berval nconn_bv = BER_BVC( "cn=connection " );
- if ( ldap_bv2rdn( ndn, &values, (char **)&text,
- LDAP_DN_FORMAT_LDAP ) )
+
+ /* create exactly the required entry;
+ * the normalized DN must start with "cn=connection ",
+ * followed by the connection id, followed by
+ * the RDN separator "," */
+ if ( ndn->bv_len <= nconn_bv.bv_len
+ || strncmp( ndn->bv_val, nconn_bv.bv_val, nconn_bv.bv_len ) != 0 )
{
- return( -1 );
+ return -1;
}
- assert( values );
- assert( values[ 0 ] );
-
- connid = atol( values[ 0 ]->la_value.bv_val
- + sizeof( CONN_CN_PREFIX ) );
-
- ldap_rdnfree( values );
+ connid = strtol( &ndn->bv_val[ nconn_bv.bv_len ], &next, 10 );
+ if ( next[ 0 ] != ',' ) {
+ return -1;
+ }
for ( c = connection_first( &connindex );
c != NULL;
c = connection_next( c, &connindex )) {
if ( c->c_connid == connid ) {
if ( conn_create( mi, c, ep ) || *ep == NULL ) {
- connection_done( c );
- return( -1 );
+ rc = -1;
}
break;
}
connection_done(c);
-
}
- return( 0 );
+ return rc;
}
)
{
struct monitorinfo *mi;
- Entry *e, *e_database, *e_tmp;
+ Entry *e_database, **ep;
int i;
struct monitorentrypriv *mp;
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn,
- &e_database ) ) {
+ &e_database ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_database_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
(void)init_readOnly( mi, e_database, frontendDB->be_restrictops );
(void)init_restrictedOperation( mi, e_database, frontendDB->be_restrictops );
- e_tmp = NULL;
- for ( i = nBackendDB; i--; ) {
+ mp = ( struct monitorentrypriv * )e_database->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
+
+ for ( i = 0; i < nBackendDB; i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
int j;
slap_overinfo *oi = NULL;
BackendInfo *bi;
+ Entry *e;
be = &backendDB[i];
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_database_init: "
- "unable to create entry 'cn=Database %d,%s'\n%s",
- i,
- monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val,
- "" );
+ "unable to create entry \"cn=Database %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val, 0 );
return( -1 );
}
}
#endif /* defined(SLAPD_LDAP) */
- for ( j = nBackendInfo; j--; ) {
+ for ( j = 0; j < nBackendInfo; j++ ) {
if ( backendInfo[ j ].bi_type == bi->bi_type ) {
struct berval bv;
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_DATABASE];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_DATABASE].mss_flags
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_database_init: "
- "unable to add entry 'cn=Database %d,%s'\n",
- i,
- monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val,
- 0 );
+ "unable to add entry \"cn=Database %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_ndn.bv_val, 0 );
return( -1 );
}
monitor_back_add_plugin( be, e );
#endif /* defined(LDAP_SLAPI) */
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- mp = ( struct monitorentrypriv * )e_database->e_private;
- mp->mp_children = e_tmp;
-
monitor_cache_release( mi, e_database );
return( 0 );
*/
struct monitorsubsys monitor_subsys[] = {
{
- SLAPD_MONITOR_LISTENER, SLAPD_MONITOR_LISTENER_NAME,
- BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_PERSISTENT_CH,
- monitor_subsys_listener_init,
- NULL, /* update */
- NULL, /* create */
- NULL /* modify */
- }, {
- SLAPD_MONITOR_DATABASE, SLAPD_MONITOR_DATABASE_NAME,
- BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_PERSISTENT_CH,
- monitor_subsys_database_init,
- NULL, /* update */
- NULL, /* create */
- monitor_subsys_database_modify
- }, {
- SLAPD_MONITOR_BACKEND, SLAPD_MONITOR_BACKEND_NAME,
+ SLAPD_MONITOR_BACKEND_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_PERSISTENT_CH,
monitor_subsys_backend_init,
NULL, /* create */
NULL /* modify */
}, {
- SLAPD_MONITOR_THREAD, SLAPD_MONITOR_THREAD_NAME,
- BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_NONE,
- monitor_subsys_thread_init,
- monitor_subsys_thread_update,
- NULL, /* create */
- NULL /* modify */
- }, {
- SLAPD_MONITOR_SASL, SLAPD_MONITOR_SASL_NAME,
- BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_NONE,
- NULL, /* init */
- NULL, /* update */
- NULL, /* create */
- NULL /* modify */
- }, {
- SLAPD_MONITOR_TLS, SLAPD_MONITOR_TLS_NAME,
- BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_NONE,
- NULL, /* init */
- NULL, /* update */
- NULL, /* create */
- NULL /* modify */
- }, {
- SLAPD_MONITOR_CONN, SLAPD_MONITOR_CONN_NAME,
+ SLAPD_MONITOR_CONN_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_VOLATILE_CH,
monitor_subsys_conn_init,
monitor_subsys_conn_create,
NULL /* modify */
}, {
- SLAPD_MONITOR_RWW, SLAPD_MONITOR_RWW_NAME,
+ SLAPD_MONITOR_DATABASE_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_PERSISTENT_CH,
- monitor_subsys_rww_init,
- monitor_subsys_rww_update,
- NULL, /* create */
+ monitor_subsys_database_init,
+ NULL, /* update */
+ NULL, /* create */
+ monitor_subsys_database_modify
+ }, {
+ SLAPD_MONITOR_LISTENER_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_PERSISTENT_CH,
+ monitor_subsys_listener_init,
+ NULL, /* update */
+ NULL, /* create */
NULL /* modify */
}, {
- SLAPD_MONITOR_LOG, SLAPD_MONITOR_LOG_NAME,
+ SLAPD_MONITOR_LOG_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_NONE,
monitor_subsys_log_init,
NULL, /* create */
monitor_subsys_log_modify
}, {
- SLAPD_MONITOR_OPS, SLAPD_MONITOR_OPS_NAME,
+ SLAPD_MONITOR_OPS_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_PERSISTENT_CH,
monitor_subsys_ops_init,
NULL, /* create */
NULL, /* modify */
}, {
- SLAPD_MONITOR_SENT, SLAPD_MONITOR_SENT_NAME,
+ SLAPD_MONITOR_OVERLAY_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_PERSISTENT_CH,
+ monitor_subsys_overlay_init,
+ NULL, /* update */
+ NULL, /* create */
+ NULL, /* modify */
+ }, {
+ SLAPD_MONITOR_SASL_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_NONE,
+ NULL, /* init */
+ NULL, /* update */
+ NULL, /* create */
+ NULL /* modify */
+ }, {
+ SLAPD_MONITOR_SENT_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_PERSISTENT_CH,
monitor_subsys_sent_init,
NULL, /* create */
NULL, /* modify */
}, {
- SLAPD_MONITOR_TIME, SLAPD_MONITOR_TIME_NAME,
+ SLAPD_MONITOR_THREAD_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_PERSISTENT_CH,
+ monitor_subsys_thread_init,
+ monitor_subsys_thread_update,
+ NULL, /* create */
+ NULL /* modify */
+ }, {
+ SLAPD_MONITOR_TIME_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
MONITOR_F_PERSISTENT_CH,
monitor_subsys_time_init,
NULL, /* create */
NULL, /* modify */
}, {
- SLAPD_MONITOR_OVERLAY, SLAPD_MONITOR_OVERLAY_NAME,
+ SLAPD_MONITOR_TLS_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
- MONITOR_F_PERSISTENT_CH,
- monitor_subsys_overlay_init,
- NULL, /* update */
+ MONITOR_F_NONE,
+ NULL, /* init */
+ NULL, /* update */
NULL, /* create */
- NULL, /* modify */
- }, { -1, NULL }
+ NULL /* modify */
+ }, {
+ SLAPD_MONITOR_RWW_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_PERSISTENT_CH,
+ monitor_subsys_rww_init,
+ monitor_subsys_rww_update,
+ NULL, /* create */
+ NULL /* modify */
+ }, { NULL }
};
#if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
&err, LDAP_SCHEMA_ALLOW_ALL );
if ( !at ) {
Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
- "in AttributeType '%s' %s before %s\n",
+ "in AttributeType \"%s\" %s before %s\n",
mat[i].name, ldap_scherr2str(code), err );
return -1;
}
if ( at->at_oid == NULL ) {
Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
- "null OID for attributeType '%s'\n",
+ "null OID for attributeType \"%s\"\n",
mat[i].name, 0, 0 );
return -1;
}
code = at_add(at, &err);
if ( code ) {
Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: "
- "%s in attributeType '%s'\n",
+ "%s in attributeType \"%s\"\n",
scherr2str(code), mat[i].name, 0 );
return -1;
}
LDAP_SCHEMA_ALLOW_ALL );
if ( !oc ) {
Debug( LDAP_DEBUG_ANY,
- "unable to parse monitor objectclass '%s': "
+ "unable to parse monitor objectclass \"%s\": "
"%s before %s\n" , moc[i].name,
ldap_scherr2str(code), err );
return -1;
if ( oc->oc_oid == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "objectclass '%s' has no OID\n" ,
+ "objectclass \"%s\" has no OID\n" ,
moc[i].name, 0, 0 );
return -1;
}
code = oc_add(oc, 0, &err);
if ( code ) {
Debug( LDAP_DEBUG_ANY,
- "objectclass '%s': %s \"%s\"\n" ,
+ "objectclass \"%s\": %s \"%s\"\n" ,
moc[i].name, scherr2str(code), err );
return -1;
}
{
struct monitorinfo *mi = (struct monitorinfo *)be->be_private;
struct monitorsubsys *ms;
- Entry *e, *e_tmp;
+ Entry *e, **ep;
struct monitorentrypriv *mp;
int i;
char buf[ BACKMONITOR_BUFSIZE ], *end_of_line;
mi->mi_creatorsName = be->be_rootdn;
}
+ /*
+ * creates the "cn=Monitor" entry
+ */
+ snprintf( buf, sizeof( buf ),
+ "dn: %s\n"
+ "objectClass: %s\n"
+ "structuralObjectClass: %s\n"
+ "cn: Monitor\n"
+ "%s: This subtree contains monitoring/managing objects.\n"
+ "%s: This object contains information about this server.\n"
+#if 0
+ "%s: createTimestamp reflects the time this server instance was created.\n"
+ "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
+#endif
+ "creatorsName: %s\n"
+ "modifiersName: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
+ SLAPD_MONITOR_DN,
+ mi->mi_oc_monitorServer->soc_cname.bv_val,
+ mi->mi_oc_monitorServer->soc_cname.bv_val,
+ mi->mi_ad_description->ad_cname.bv_val,
+ mi->mi_ad_description->ad_cname.bv_val,
+#if 0
+ mi->mi_ad_description->ad_cname.bv_val,
+ mi->mi_ad_description->ad_cname.bv_val,
+#endif
+ mi->mi_creatorsName.bv_val,
+ mi->mi_creatorsName.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
+
+ e = str2entry( buf );
+ if ( e == NULL) {
+ Debug( LDAP_DEBUG_ANY,
+ "unable to create \"%s\" entry\n",
+ SLAPD_MONITOR_DN, 0, 0 );
+ return( -1 );
+ }
+
+ bv.bv_val = (char *) Versionstr;
+ end_of_line = strchr( Versionstr, '\n' );
+ if ( end_of_line ) {
+ bv.bv_len = end_of_line - Versionstr;
+ } else {
+ bv.bv_len = strlen( Versionstr );
+ }
+
+ if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
+ &bv, NULL ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "unable to add monitoredInfo to \"%s\" entry\n",
+ SLAPD_MONITOR_DN, 0, 0 );
+ return( -1 );
+ }
+
+ if ( mi->mi_l.bv_len ) {
+ if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "unable to add locality to \"%s\" entry\n",
+ SLAPD_MONITOR_DN, 0, 0 );
+ return( -1 );
+ }
+ }
+
+ mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
+ e->e_private = ( void * )mp;
+
+ mp->mp_info = NULL;
+ mp->mp_children = NULL;
+ mp->mp_next = NULL;
+
+ ep = &mp->mp_children;
+
+ if ( monitor_cache_add( mi, e ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "unable to add entry \"%s\" to cache\n",
+ SLAPD_MONITOR_DN, 0, 0 );
+ return -1;
+ }
+
/*
* Create all the subsystem specific entries
*/
- e_tmp = NULL;
for ( i = 0; monitor_subsys[ i ].mss_name != NULL; i++ ) {
int len = strlen( monitor_subsys[ i ].mss_name );
struct berval dn;
if ( e == NULL) {
Debug( LDAP_DEBUG_ANY,
- "unable to create '%s' entry\n",
+ "unable to create \"%s\" entry\n",
monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
+ mp->mp_next = NULL;
mp->mp_info = &monitor_subsys[ i ];
mp->mp_children = NULL;
- mp->mp_next = e_tmp;
mp->mp_flags = monitor_subsys[ i ].mss_flags;
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
- "unable to add entry '%s' to cache\n",
+ "unable to add entry \"%s\" to cache\n",
monitor_subsys[ i ].mss_dn.bv_val, 0, 0 );
return -1;
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- /*
- * creates the "cn=Monitor" entry
- */
- snprintf( buf, sizeof( buf ),
- "dn: %s\n"
- "objectClass: %s\n"
- "structuralObjectClass: %s\n"
- "cn: Monitor\n"
- "%s: This subtree contains monitoring/managing objects.\n"
- "%s: This object contains information about this server.\n"
-#if 0
- "%s: createTimestamp reflects the time this server instance was created.\n"
- "%s: modifyTimestamp reflects the time this server instance was last accessed.\n"
-#endif
- "creatorsName: %s\n"
- "modifiersName: %s\n"
- "createTimestamp: %s\n"
- "modifyTimestamp: %s\n",
- SLAPD_MONITOR_DN,
- mi->mi_oc_monitorServer->soc_cname.bv_val,
- mi->mi_oc_monitorServer->soc_cname.bv_val,
- mi->mi_ad_description->ad_cname.bv_val,
- mi->mi_ad_description->ad_cname.bv_val,
-#if 0
- mi->mi_ad_description->ad_cname.bv_val,
- mi->mi_ad_description->ad_cname.bv_val,
-#endif
- mi->mi_creatorsName.bv_val,
- mi->mi_creatorsName.bv_val,
- mi->mi_startTime.bv_val,
- mi->mi_startTime.bv_val );
-
- e = str2entry( buf );
- if ( e == NULL) {
- Debug( LDAP_DEBUG_ANY,
- "unable to create '%s' entry\n",
- SLAPD_MONITOR_DN, 0, 0 );
- return( -1 );
- }
-
- bv.bv_val = (char *) Versionstr;
- end_of_line = strchr( Versionstr, '\n' );
- if ( end_of_line ) {
- bv.bv_len = end_of_line - Versionstr;
- } else {
- bv.bv_len = strlen( Versionstr );
- }
-
- if ( attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
- &bv, NULL ) ) {
- Debug( LDAP_DEBUG_ANY,
- "unable to add monitoredInfo to '%s' entry\n",
- SLAPD_MONITOR_DN, 0, 0 );
- return( -1 );
- }
-
- if ( mi->mi_l.bv_len ) {
- if ( attr_merge_normalize_one( e, mi->mi_ad_l, &mi->mi_l, NULL ) ) {
- Debug( LDAP_DEBUG_ANY,
- "unable to add locality to '%s' entry\n",
- SLAPD_MONITOR_DN, 0, 0 );
- return( -1 );
- }
- }
-
- mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
- e->e_private = ( void * )mp;
-
- mp->mp_info = NULL;
- mp->mp_children = e_tmp;
- mp->mp_next = NULL;
-
- if ( monitor_cache_add( mi, e ) ) {
- Debug( LDAP_DEBUG_ANY,
- "unable to add entry '%s' to cache\n",
- SLAPD_MONITOR_DN, 0, 0 );
- return -1;
- }
+ assert( be );
be->be_private = mi;
- assert( be );
-
/*
* opens the monitor backend
*/
)
{
struct monitorinfo *mi;
- Entry *e, *e_listener, *e_tmp;
+ Entry *e_listener, **ep;
int i;
struct monitorentrypriv *mp;
Listener **l;
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn,
- &e_listener ) ) {
+ &e_listener ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_listener_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
- for ( i = 0; l[i]; i++ );
- for ( ; i--; ) {
+ mp = ( struct monitorentrypriv * )e_listener->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
+
+ for ( i = 0; l[i]; i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
+ Entry *e;
snprintf( buf, sizeof( buf ),
"dn: cn=Listener %d,%s\n"
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_listener_init: "
- "unable to create entry 'cn=Listener %d,%s'\n%s",
- i,
- monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
- "" );
+ "unable to create entry \"cn=Listener %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
return( -1 );
}
if ( l[i]->sl_is_udp ) {
struct berval bv;
- bv.bv_val = "UDP";
- bv.bv_len = sizeof("UDP")-1;
-
+ BER_BVSTR( &bv, "UDP" );
attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
&bv, NULL );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_LISTENER];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_LISTENER].mss_flags
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_listener_init: "
- "unable to add entry 'cn=Listener %d,%s'\n",
- i,
- monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
- 0 );
+ "unable to add entry \"cn=Listener %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- mp = ( struct monitorentrypriv * )e_listener->e_private;
- mp->mp_children = e_tmp;
-
monitor_cache_release( mi, e_listener );
return( 0 );
&e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_log_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
/* initialize the debug level(s) */
for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
-
if ( mi->mi_ad_managedInfo->ad_type->sat_equality->smr_normalize ) {
int rc;
struct berval rdn;
struct berval nrdn;
} monitor_op[] = {
- { BER_BVC( "cn=Bind" ), BER_BVC( "cn=bind" ) },
- { BER_BVC( "cn=Unbind" ), BER_BVC( "cn=unbind" ) },
- { BER_BVC( "cn=Add" ), BER_BVC( "cn=add" ) },
- { BER_BVC( "cn=Delete" ), BER_BVC( "cn=delete" ) },
- { BER_BVC( "cn=Modrdn" ), BER_BVC( "cn=modrdn" ) },
- { BER_BVC( "cn=Modify" ), BER_BVC( "cn=modify" ) },
- { BER_BVC( "cn=Compare" ), BER_BVC( "cn=compare" ) },
- { BER_BVC( "cn=Search" ), BER_BVC( "cn=search" ) },
- { BER_BVC( "cn=Abandon" ), BER_BVC( "cn=abandon" ) },
- { BER_BVC( "cn=Extended" ), BER_BVC( "cn=extended" ) },
- { BER_BVNULL, BER_BVNULL }
+ { BER_BVC( "cn=Bind" ), BER_BVNULL },
+ { BER_BVC( "cn=Unbind" ), BER_BVNULL },
+ { BER_BVC( "cn=Add" ), BER_BVNULL },
+ { BER_BVC( "cn=Delete" ), BER_BVNULL },
+ { BER_BVC( "cn=Modrdn" ), BER_BVNULL },
+ { BER_BVC( "cn=Modify" ), BER_BVNULL },
+ { BER_BVC( "cn=Compare" ), BER_BVNULL },
+ { BER_BVC( "cn=Search" ), BER_BVNULL },
+ { BER_BVC( "cn=Abandon" ), BER_BVNULL },
+ { BER_BVC( "cn=Extended" ), BER_BVNULL },
+ { BER_BVNULL, BER_BVNULL }
};
int
{
struct monitorinfo *mi;
- Entry *e, *e_tmp, *e_op;
+ Entry *e_op, **ep;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
int i;
mi = ( struct monitorinfo * )be->be_private;
if ( monitor_cache_get( mi,
- &monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, &e_op ) ) {
+ &monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn, &e_op ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_ops_init: "
"unable to get entry \"%s\"\n",
attr_merge_one( e_op, mi->mi_ad_monitorOpInitiated, &bv_zero, NULL );
attr_merge_one( e_op, mi->mi_ad_monitorOpCompleted, &bv_zero, NULL );
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_op->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
- for ( i = SLAP_OP_LAST; i-- > 0; ) {
+ for ( i = 0; i < SLAP_OP_LAST; i++ ) {
+ struct berval rdn;
+ Entry *e;
/*
* Initiated ops
return( -1 );
}
+ /* steal normalized RDN */
+ dnRdn( &e->e_nname, &rdn );
+ ber_dupbv( &monitor_op[i].nrdn, &rdn );
+
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OPS];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OPS].mss_flags \
monitor_subsys[SLAPD_MONITOR_OPS].mss_ndn.bv_val, 0 );
return( -1 );
}
-
- e_tmp = e;
- }
- mp = ( struct monitorentrypriv * )e_op->e_private;
- mp->mp_children = e_tmp;
+ *ep = e;
+ ep = &mp->mp_next;
+ }
monitor_cache_release( mi, e_op );
#else /* ! HAVE_GMP */
unsigned long nInitiated = 0,
nCompleted = 0;
- char buf[] = "+9223372036854775807L";
#endif /* ! HAVE_GMP */
struct berval rdn;
int i;
#ifdef HAVE_GMP
mpz_init( nInitiated );
mpz_init( nCompleted );
-#endif /* ! HAVE_GMP */
+#endif /* HAVE_GMP */
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex );
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpInitiated );
assert ( a != NULL );
- free( a->a_vals[ 0 ].bv_val );
+
+ /* NOTE: no minus sign is allowed in the counters... */
+ UI2BV( &a->a_vals[ 0 ], nInitiated );
#ifdef HAVE_GMP
- /* NOTE: there should be no minus sign allowed in the counters... */
- a->a_vals[ 0 ].bv_len = mpz_sizeinbase( nInitiated, 10 );
- a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
- (void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, nInitiated );
mpz_clear( nInitiated );
- /* NOTE: according to the documentation, the result
- * of mpz_sizeinbase() can exceed the length of the
- * string representation of the number by 1
- */
- if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
- a->a_vals[ 0 ].bv_len--;
- }
-#else /* ! HAVE_GMP */
- snprintf( buf, sizeof( buf ), "%ld", nInitiated );
- ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
-#endif /* ! HAVE_GMP */
+#endif /* HAVE_GMP */
a = attr_find( e->e_attrs, mi->mi_ad_monitorOpCompleted );
assert ( a != NULL );
- free( a->a_vals[ 0 ].bv_val );
+
+ /* NOTE: no minus sign is allowed in the counters... */
+ UI2BV( &a->a_vals[ 0 ], nCompleted );
#ifdef HAVE_GMP
- /* NOTE: there should be no minus sign allowed in the counters... */
- a->a_vals[ 0 ].bv_len = mpz_sizeinbase( nCompleted, 10 );
- a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
- (void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, nCompleted );
mpz_clear( nCompleted );
- /* NOTE: according to the documentation, the result
- * of mpz_sizeinbase() can exceed the length of the
- * string representation of the number by 1
- */
- if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
- a->a_vals[ 0 ].bv_len--;
- }
-#else /* ! HAVE_GMP */
- snprintf( buf, sizeof( buf ), "%ld", nCompleted );
- ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
-#endif /* ! HAVE_GMP */
-
+#endif /* HAVE_GMP */
+
return( 0 );
}
)
{
struct monitorinfo *mi;
- Entry *e, *e_overlay, *e_tmp;
+ Entry *e_overlay, **ep;
int i;
struct monitorentrypriv *mp;
slap_overinst *on;
if ( monitor_cache_get( mi,
&monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn,
- &e_overlay ) ) {
+ &e_overlay ) )
+ {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_overlay_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_overlay->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
+
for ( on = overlay_next( NULL ), i = 0; on; on = overlay_next( on ), i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
struct berval bv;
int j;
+ Entry *e;
snprintf( buf, sizeof( buf ),
"dn: cn=Overlay %d,%s\n"
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_overlay_init: "
- "unable to create entry 'cn=Overlay %d,%s'\n%s",
- i,
- monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
- "" );
+ "unable to create entry \"cn=Overlay %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_overlay_init: "
- "unable to add entry 'cn=Overlay %d,%s'\n%s",
- i,
- monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
- "" );
+ "unable to add entry \"cn=Overlay %d,%s\"\n",
+ i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- mp = ( struct monitorentrypriv * )e_overlay->e_private;
- mp->mp_children = e_tmp;
-
monitor_cache_release( mi, e_overlay );
return( 0 );
int monitor_subsys_time_init LDAP_P(( BackendDB *be ));
int monitor_subsys_time_update LDAP_P(( Operation *op, Entry *e ));
+/* NOTE: this macro assumes that bv has been allocated
+ * by ber_* malloc functions or is { 0L, NULL } */
+#ifdef HAVE_GMP
+/* NOTE: according to the documentation, the result
+ * of mpz_sizeinbase() can exceed the length of the
+ * string representation of the number by 1
+ */
+#define UI2BV(bv,ui) \
+ do { \
+ ber_len_t len = mpz_sizeinbase( (ui), 10 ); \
+ if ( len > (bv)->bv_len ) { \
+ (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \
+ } \
+ (void)mpz_get_str( (bv)->bv_val, 10, (ui) ); \
+ if ( (bv)->bv_val[ len - 1 ] == '\0' ) { \
+ len--; \
+ } \
+ (bv)->bv_len = len; \
+ } while ( 0 )
+#else /* ! HAVE_GMP */
+#define UI2BV(bv,ui) \
+ do { \
+ char buf[] = "+9223372036854775807L"; \
+ ber_len_t len; \
+ snprintf( buf, sizeof( buf ), "%lu", (ui) ); \
+ len = strlen( buf ); \
+ if ( len > (bv)->bv_len ) { \
+ (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \
+ } \
+ AC_MEMCPY( (bv)->bv_val, buf, len + 1 ); \
+ } while ( 0 )
+#endif /* ! HAVE_GMP */
+
LDAP_END_DECL
#endif /* _PROTO_BACK_MONITOR */
{
struct monitorinfo *mi;
- Entry *e, *e_tmp, *e_conn;
+ Entry *e, **ep, *e_conn;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
struct berval bv;
&monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn, &e_conn ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_rww_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_conn->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
/*
* Total conns
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_rww_init: "
- "unable to create entry 'cn=Read,%s'\n",
+ "unable to create entry \"cn=Read,%s\"\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_RWW];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_RWW].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_rww_init: "
- "unable to add entry 'cn=Read,%s'\n",
+ "unable to add entry \"cn=Read,%s\"\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
/*
* Current conns
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_rww_init: "
- "unable to create entry 'cn=Write,%s'\n",
+ "unable to create entry \"cn=Write,%s\"\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_RWW];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_RWW].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_rww_init: "
- "unable to add entry 'cn=Write,%s'\n",
+ "unable to add entry \"cn=Write,%s\"\n",
monitor_subsys[SLAPD_MONITOR_RWW].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = e;
-
- mp = ( struct monitorentrypriv * )e_conn->e_private;
- mp->mp_children = e_tmp;
+ *ep = e;
+ ep = &mp->mp_next;
monitor_cache_release( mi, e_conn );
int rc = LDAP_SUCCESS;
Entry *e, *matched = NULL;
- Debug(LDAP_DEBUG_TRACE, "=> monitor_back_search\n%s%s%s", "", "", "");
+ Debug( LDAP_DEBUG_TRACE, "=> monitor_back_search\n", 0, 0, 0 );
/* get entry with reader lock */
{
struct monitorinfo *mi;
- Entry *e_tmp, *e_sent;
+ Entry **ep, *e_sent;
struct monitorentrypriv *mp;
int i;
&monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, &e_sent ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_sent_init: "
- "unable to get entry \"%s\"\n%s%s",
- monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_sent->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
- for ( i = MONITOR_SENT_LAST; --i >= 0; ) {
+ for ( i = 0; i < MONITOR_SENT_LAST; i++ ) {
char buf[ BACKMONITOR_BUFSIZE ];
struct berval rdn, bv;
Entry *e;
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_SENT];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_SENT].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_sent_init: "
- "unable to add entry \"%s,%s\"\n%s%s",
+ "unable to add entry \"%s,%s\"\n",
monitor_sent[i].rdn.bv_val,
monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
}
- mp = ( struct monitorentrypriv * )e_sent->e_private;
- mp->mp_children = e_tmp;
-
monitor_cache_release( mi, e_sent );
return( 0 );
unsigned long n;
#endif /* ! HAVE_GMP */
Attribute *a;
-#ifndef HAVE_GMP
- char buf[] = "+9223372036854775807L";
-#endif /* ! HAVE_GMP */
int i;
assert( mi );
ldap_pvt_thread_mutex_unlock(&slap_counters.sc_sent_mutex);
a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
- if ( a == NULL ) {
- return -1;
- }
+ assert( a );
- free( a->a_vals[ 0 ].bv_val );
+ /* NOTE: no minus sign is allowed in the counters... */
+ UI2BV( &a->a_vals[ 0 ], n );
#ifdef HAVE_GMP
- /* NOTE: there should be no minus sign allowed in the counters... */
- a->a_vals[ 0 ].bv_len = mpz_sizeinbase( n, 10 );
- a->a_vals[ 0 ].bv_val = ber_memalloc( a->a_vals[ 0 ].bv_len + 1 );
- (void)mpz_get_str( a->a_vals[ 0 ].bv_val, 10, n );
mpz_clear( n );
- /* NOTE: according to the documentation, the result
- * of mpz_sizeinbase() can exceed the length of the
- * string representation of the number by 1
- */
- if ( a->a_vals[ 0 ].bv_val[ a->a_vals[ 0 ].bv_len - 1 ] == '\0' ) {
- a->a_vals[ 0 ].bv_len--;
- }
-#else /* ! HAVE_GMP */
- snprintf( buf, sizeof( buf ), "%lu", n );
- ber_str2bv( buf, 0, 1, &a->a_vals[ 0 ] );
-#endif /* ! HAVE_GMP */
+#endif /* HAVE_GMP */
return 0;
}
)
{
struct monitorinfo *mi;
- Entry *e;
+ struct monitorentrypriv *mp;
+ Entry *e, **ep, *e_thread;
static char buf[ BACKMONITOR_BUFSIZE ];
- struct berval bv;
mi = ( struct monitorinfo * )be->be_private;
if ( monitor_cache_get( mi,
- &monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn, &e ) )
+ &monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn, &e_thread ) )
{
Debug( LDAP_DEBUG_ANY,
- "monitor_subsys_thread_init: unable to get entry '%s'\n",
+ "monitor_subsys_thread_init: unable to get entry \"%s\"\n",
monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val,
0, 0 );
return( -1 );
}
- /* initialize the thread number */
- snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max );
+ mp = ( struct monitorentrypriv * )e_thread->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
+
+ /*
+ * Max
+ */
+ snprintf( buf, sizeof( buf ),
+ "dn: cn=Max,%s\n"
+ "objectClass: %s\n"
+ "structuralObjectClass: %s\n"
+ "cn: Max\n"
+ "%s: %d\n"
+ "creatorsName: %s\n"
+ "modifiersName: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_dn.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ mi->mi_ad_monitoredInfo->ad_cname.bv_val,
+ connection_pool_max,
+ mi->mi_creatorsName.bv_val,
+ mi->mi_creatorsName.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
+
+ e = str2entry( buf );
+ if ( e == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_thread_init: "
+ "unable to create entry \"cn=Max,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
+ return( -1 );
+ }
+
+ mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
+ e->e_private = ( void * )mp;
+ mp->mp_next = NULL;
+ mp->mp_children = NULL;
+ mp->mp_info = &monitor_subsys[SLAPD_MONITOR_THREAD];
+ mp->mp_flags = monitor_subsys[SLAPD_MONITOR_THREAD].mss_flags \
+ | MONITOR_F_SUB | MONITOR_F_PERSISTENT;
+
+ if ( monitor_cache_add( mi, e ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_thread_init: "
+ "unable to add entry \"cn=Max,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
+ return( -1 );
+ }
+
+ *ep = e;
+ ep = &mp->mp_next;
+
+ /*
+ * Backload
+ */
+ snprintf( buf, sizeof( buf ),
+ "dn: cn=Backload,%s\n"
+ "objectClass: %s\n"
+ "structuralObjectClass: %s\n"
+ "cn: Backload\n"
+ "%s: 0\n"
+ "creatorsName: %s\n"
+ "modifiersName: %s\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_dn.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ mi->mi_ad_monitoredInfo->ad_cname.bv_val,
+ mi->mi_creatorsName.bv_val,
+ mi->mi_creatorsName.bv_val,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
+
+ e = str2entry( buf );
+ if ( e == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_thread_init: "
+ "unable to create entry \"cn=Backload,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
+ return( -1 );
+ }
- bv.bv_val = buf;
- bv.bv_len = strlen( bv.bv_val );
+ mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
+ e->e_private = ( void * )mp;
+ mp->mp_next = NULL;
+ mp->mp_children = NULL;
+ mp->mp_info = &monitor_subsys[SLAPD_MONITOR_THREAD];
+ mp->mp_flags = monitor_subsys[SLAPD_MONITOR_THREAD].mss_flags \
+ | MONITOR_F_SUB | MONITOR_F_PERSISTENT;
- attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
+ if ( monitor_cache_add( mi, e ) ) {
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_thread_init: "
+ "unable to add entry \"cn=Backload,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
+ return( -1 );
+ }
+
+ *ep = e;
+ ep = &mp->mp_next;
- monitor_cache_release( mi, e );
+ monitor_cache_release( mi, e_thread );
return( 0 );
}
Entry *e
)
{
- struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
+ struct monitorinfo *mi =
+ (struct monitorinfo *)op->o_bd->be_private;
Attribute *a;
- struct berval *b = NULL;
char buf[ BACKMONITOR_BUFSIZE ];
+ static struct berval backload_bv = BER_BVC( "cn=backload" );
+ struct berval rdn;
+ ber_len_t len;
assert( mi != NULL );
- snprintf( buf, sizeof( buf ), "backload=%d",
- ldap_pvt_thread_pool_backload( &connection_pool ) );
+ dnRdn( &e->e_nname, &rdn );
+ if ( !dn_match( &rdn, &backload_bv ) ) {
+ return 0;
+ }
a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo );
- if ( a != NULL ) {
- for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
- if ( strncmp( b[0].bv_val, "backload=",
- sizeof( "backload=" ) - 1 ) == 0 ) {
- free( b[0].bv_val );
- ber_str2bv( buf, 0, 1, &b[0] );
- break;
- }
- }
+ if ( a == NULL ) {
+ return -1;
}
- if ( b == NULL || b[0].bv_val == NULL ) {
- struct berval bv;
-
- bv.bv_val = buf;
- bv.bv_len = strlen( buf );
- attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
- &bv, NULL );
+ snprintf( buf, sizeof( buf ), "%d",
+ ldap_pvt_thread_pool_backload( &connection_pool ) );
+ len = strlen( buf );
+ if ( len > a->a_vals[ 0 ].bv_len ) {
+ a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 );
}
+ a->a_vals[ 0 ].bv_len = len;
+ AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
return( 0 );
}
{
struct monitorinfo *mi;
- Entry *e, *e_tmp, *e_time;
+ Entry *e, **ep, *e_time;
struct monitorentrypriv *mp;
char buf[ BACKMONITOR_BUFSIZE ];
&monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn, &e_time ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_time_init: "
- "unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val,
- "", "" );
+ "unable to get entry \"%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = NULL;
+ mp = ( struct monitorentrypriv * )e_time->e_private;
+ mp->mp_children = NULL;
+ ep = &mp->mp_children;
snprintf( buf, sizeof( buf ),
"dn: cn=Start,%s\n"
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_time_init: "
- "unable to create entry 'cn=Start,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val,
- "", "" );
+ "unable to create entry \"cn=Start,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_TIME];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_TIME].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_time_init: "
- "unable to add entry 'cn=Start,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val,
- "", "" );
+ "unable to add entry \"cn=Start,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = e;
+ *ep = e;
+ ep = &mp->mp_next;
/*
* Current
if ( e == NULL ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_time_init: "
- "unable to create entry 'cn=Current,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val,
- "", "" );
+ "unable to create entry \"cn=Current,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp;
- mp->mp_next = e_tmp;
+ mp->mp_next = NULL;
mp->mp_children = NULL;
mp->mp_info = &monitor_subsys[SLAPD_MONITOR_TIME];
mp->mp_flags = monitor_subsys[SLAPD_MONITOR_TIME].mss_flags \
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_time_init: "
- "unable to add entry 'cn=Current,%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val,
- "", "" );
+ "unable to add entry \"cn=Current,%s\"\n",
+ monitor_subsys[SLAPD_MONITOR_TIME].mss_ndn.bv_val, 0, 0 );
return( -1 );
}
- e_tmp = e;
-
- mp = ( struct monitorentrypriv * )e_time->e_private;
- mp->mp_children = e_tmp;
+ *ep = e;
+ ep = &mp->mp_next;
monitor_cache_release( mi, e_time );
Entry *e
)
{
- struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
+ struct monitorinfo *mi =
+ (struct monitorinfo *)op->o_bd->be_private;
+
+ static struct berval bv_current = BER_BVC( "cn=current" );
+ struct berval rdn;
assert( mi );
assert( e );
+
+ dnRdn( &e->e_nname, &rdn );
- if ( strncmp( e->e_nname.bv_val, "cn=current",
- sizeof("cn=current") - 1 ) == 0 ) {
+ if ( dn_match( &rdn, &bv_current ) ) {
struct tm *tm;
#ifdef HAVE_GMTIME_R
struct tm tm_buf;
assert( c->c_conn_state != SLAP_C_INVALID );
assert( sd != AC_SOCKET_INVALID );
-#ifdef SLAPD_MONITOR
- c->c_activitytime = slap_get_time();
-#else
- if( global_idletimeout > 0 ) {
+#ifndef SLAPD_MONITOR
+ if ( global_idletimeout > 0 )
+#endif /* ! SLAPD_MONITOR */
+ {
c->c_activitytime = slap_get_time();
}
-#endif
}
return c;
/* set to zero until bind, implies LDAP_VERSION3 */
c->c_protocol = 0;
-#ifdef SLAPD_MONITOR
- c->c_activitytime = c->c_starttime = slap_get_time();
-#else
- if( global_idletimeout > 0 ) {
+#ifndef SLAPD_MONITOR
+ if ( global_idletimeout > 0 )
+#endif /* ! SLAPD_MONITOR */
+ {
c->c_activitytime = c->c_starttime = slap_get_time();
}
-#endif
#ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0;