From ab47effcfd8a31dbaccefb1bae20ee2dd33270a1 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 12 Apr 2003 01:17:05 +0000 Subject: [PATCH] more cleanup and api rewriting (too tired to do anything better) --- servers/slapd/back-monitor/back-monitor.h | 12 ++--- servers/slapd/back-monitor/cache.c | 10 ++-- servers/slapd/back-monitor/compare.c | 2 +- servers/slapd/back-monitor/entry.c | 5 +- servers/slapd/back-monitor/init.c | 46 +++++++++---------- servers/slapd/back-monitor/log.c | 4 +- servers/slapd/back-monitor/modify.c | 4 +- .../slapd/back-monitor/proto-back-monitor.h | 3 +- servers/slapd/back-monitor/search.c | 2 +- 9 files changed, 41 insertions(+), 47 deletions(-) diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index f90981ff0a..5db9355f01 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -41,8 +41,6 @@ LDAP_BEGIN_DECL -#define MONITOR_DEVEL - /* * The cache maps DNs to Entries. * Each entry, on turn, holds the list of its children in the e_private field. @@ -218,8 +216,7 @@ struct monitorsubsys { int ( *mss_create )( Operation *, struct berval *ndn, Entry *, Entry ** ); /* modify entry and subentries */ - int ( *mss_modify )( Operation *, Entry *, - Modifications *modlist ); + int ( *mss_modify )( Operation *, Entry * ); }; extern struct monitorsubsys monitor_subsys[]; @@ -234,7 +231,7 @@ extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 )); extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 )); extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e )); extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep )); -extern int monitor_cache_dn2entry LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep, Entry **matched )); +extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched )); extern int monitor_cache_lock LDAP_P(( Entry *e )); extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e )); @@ -243,8 +240,9 @@ extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e )); */ extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e )); -extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn, Entry *e_parent, Entry **ep )); -extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e, Modifications *modlist )); +extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn, + Entry *e_parent, Entry **ep )); +extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e )); LDAP_END_DECL diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index d1455a1820..2d9fd75187 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -169,14 +169,14 @@ monitor_cache_get( */ int monitor_cache_dn2entry( - struct monitorinfo *mi, + Operation *op, struct berval *ndn, Entry **ep, Entry **matched ) { - int rc; - + struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private; + int rc; struct berval p_ndn = { 0L, NULL }; Entry *e_parent; struct monitorentrypriv *mp; @@ -207,7 +207,7 @@ monitor_cache_dn2entry( - ( ber_len_t ) ( p_ndn.bv_val - ndn->bv_val ); } - rc = monitor_cache_dn2entry( mi, &p_ndn, &e_parent, matched ); + rc = monitor_cache_dn2entry( op, &p_ndn, &e_parent, matched ); if ( rc || e_parent == NULL) { return( -1 ); } @@ -216,7 +216,7 @@ monitor_cache_dn2entry( rc = -1; if ( mp->mp_flags & MONITOR_F_VOLATILE_CH ) { /* parent entry generates volatile children */ - rc = monitor_entry_create( mi, ndn, e_parent, ep ); + rc = monitor_entry_create( op, ndn, e_parent, ep ); } if ( !rc ) { diff --git a/servers/slapd/back-monitor/compare.c b/servers/slapd/back-monitor/compare.c index ef57d9ffbc..9b32e9607c 100644 --- a/servers/slapd/back-monitor/compare.c +++ b/servers/slapd/back-monitor/compare.c @@ -47,7 +47,7 @@ monitor_back_compare( struct slap_op *op, struct slap_rep *rs) Attribute *a; /* get entry with reader lock */ - monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched ); + monitor_cache_dn2entry( op, &op->o_req_ndn, &e, &matched ); if ( e == NULL ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; if ( matched ) { diff --git a/servers/slapd/back-monitor/entry.c b/servers/slapd/back-monitor/entry.c index 626d6280ab..892d373c99 100644 --- a/servers/slapd/back-monitor/entry.c +++ b/servers/slapd/back-monitor/entry.c @@ -87,8 +87,7 @@ monitor_entry_create( int monitor_entry_modify( Operation *op, - Entry *e, - Modifications *modlist + Entry *e ) { struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private; @@ -101,7 +100,7 @@ monitor_entry_modify( mp = ( struct monitorentrypriv * )e->e_private; if ( mp->mp_info && mp->mp_info->mss_modify ) { - return ( *mp->mp_info->mss_modify )( op, e, modlist ); + return ( *mp->mp_info->mss_modify )( op, e ); } return( 0 ); diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 43fc20ec26..6efcdede4a 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -43,7 +43,6 @@ /* * used by many functions to add description to entries */ -AttributeDescription *monitor_ad_desc = NULL; BackendDB *be_monitor = NULL; /* @@ -250,6 +249,7 @@ monitor_back_db_init( char *schema; int offset; } moc[] = { +#ifdef MONITOR_DEVEL { "monitorServer", "( 1.3.6.1.4.1.4203.666.XXX " "NAME 'monitorServer' " "DESC 'Server monitoring root entry' " @@ -285,8 +285,10 @@ monitor_back_db_init( "DESC 'monitor monitored entity class' " "SUP monitor STRUCTURAL)", offsetof(struct monitorinfo, monitor_oc_monitoredObject) }, +#endif /* MONITOR_DEVEL */ { NULL, NULL, -1 } }, mat[] = { +#ifdef MONITOR_DEVEL { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.XXX" "NAME 'monitoredInfo' " "DESC 'monitored info' " @@ -336,6 +338,7 @@ monitor_back_db_init( "DESC 'monitor connection peer address' " "SUP monitoredInfo)", offsetof(struct monitorinfo, monitor_ad_monitorConnectionPeerAddress) }, +#endif /* MONITOR_DEVEL */ { NULL, NULL, -1 } }; @@ -380,6 +383,13 @@ monitor_back_db_init( mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 ); if ( mi == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG( OPERATION, CRIT, + "unable to initialize monitor backend\n", 0, 0, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "unable to initialize monitor backend\n", 0, 0, 0 ); +#endif return -1; } @@ -396,13 +406,13 @@ monitor_back_db_init( if ( !oc ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, CRIT, - "unable to parse monitor objectclass '%s' " - "(%s before %s)\n" , moc[i].name, + "unable to parse monitor objectclass '%s': " + "%s before %s\n" , moc[i].name, ldap_scherr2str(code), err ); #else Debug( LDAP_DEBUG_ANY, - "unable to parse monitor objectclass '%s' " - "(%s before %s)\n" , moc[i].name, + "unable to parse monitor objectclass '%s': " + "%s before %s\n" , moc[i].name, ldap_scherr2str(code), err ); #endif return -1; @@ -425,11 +435,11 @@ monitor_back_db_init( if ( code ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, CRIT, - "objectclass '%s' (%s before %s)\n" , + "objectclass '%s': %s before %s\n" , moc[i].name, scherr2str(code), err ); #else Debug( LDAP_DEBUG_ANY, - "objectclass '%s' (%s before %s)\n" , + "objectclass '%s': %s before %s\n" , moc[i].name, scherr2str(code), err ); #endif return -1; @@ -453,21 +463,10 @@ monitor_back_db_init( at = ldap_str2attributetype( mat[i].schema, &code, &err, LDAP_SCHEMA_ALLOW_ALL ); - if ( !at ) { - return 1; - } - - if ( at->at_oid == NULL ) { + if ( !at || at->at_oid == NULL ) { return 1; } - /* operational attributes should be defined internally - if ( at->at_usage ) { - fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n", - fname, lineno, at->at_oid ); - return 1; - } */ - code = at_add(at,&err); if ( code ) { return 1; @@ -482,8 +481,7 @@ monitor_back_db_init( "monitor_back_db_init: %s\n", text, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, - "monitor_subsys_backend_init: %s\n%s%s", - text, "", "" ); + "monitor_back_db_init: %s\n", text, 0, 0 ); #endif return -1; } @@ -495,8 +493,7 @@ monitor_back_db_init( "monitor_back_db_init: %s\n", text, 0, 0 ); #else Debug( LDAP_DEBUG_ANY, - "monitor_subsys_backend_init: %s\n%s%s", - text, "", "" ); + "monitor_back_db_init: %s\n", text, 0, 0 ); #endif return( -1 ); } @@ -625,7 +622,8 @@ monitor_back_db_init( } else { bv.bv_len = strlen( Versionstr ); } - if ( attr_merge_normalize_one( e, monitor_ad_desc, &bv, NULL ) ) { + if ( attr_merge_normalize_one( e, mi->monitor_ad_description, + &bv, NULL ) ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, CRIT, "unable to add description to '%s' entry\n", diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index df63d49840..326a6a9c96 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -145,14 +145,14 @@ monitor_subsys_log_init( int monitor_subsys_log_modify( Operation *op, - Entry *e, - Modifications *modlist + Entry *e ) { struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private; int rc = LDAP_OTHER; int newlevel = ldap_syslog; Attribute *save_attrs; + Modifications *modlist = op->oq_modify.rs_modlist; Modifications *ml; ldap_pvt_thread_mutex_lock( &monitor_log_mutex ); diff --git a/servers/slapd/back-monitor/modify.c b/servers/slapd/back-monitor/modify.c index 43315a7627..6eae551402 100644 --- a/servers/slapd/back-monitor/modify.c +++ b/servers/slapd/back-monitor/modify.c @@ -66,7 +66,7 @@ monitor_back_modify( Operation *op, SlapReply *rs ) #endif /* acquire and lock entry */ - monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched ); + monitor_cache_dn2entry( op, &op->o_req_ndn, &e, &matched ); if ( e == NULL ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; if ( matched ) { @@ -83,7 +83,7 @@ monitor_back_modify( Operation *op, SlapReply *rs ) if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) { rc = LDAP_INSUFFICIENT_ACCESS; } else { - rc = monitor_entry_modify( op, e, op->oq_modify.rs_modlist ); + rc = monitor_entry_modify( op, e ); } rs->sr_err = rc; diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index 42d455ccc1..0df9ee80e2 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -82,8 +82,7 @@ int monitor_subsys_writew_update LDAP_P(( Operation *op, Entry *e )); * log */ int monitor_subsys_log_init LDAP_P(( BackendDB *be )); -int monitor_subsys_log_modify LDAP_P(( Operation *op, Entry *e, - Modifications *modlist )); +int monitor_subsys_log_modify LDAP_P(( Operation *op, Entry *e )); /* * operations diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index b61ae54255..f9a6cd0d82 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -144,7 +144,7 @@ monitor_back_search( Operation *op, SlapReply *rs ) /* get entry with reader lock */ - monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched ); + monitor_cache_dn2entry( op, &op->o_req_ndn, &e, &matched ); if ( e == NULL ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; if ( matched ) { -- 2.39.5