more cleanup and api rewriting (too tired to do anything better)

This commit is contained in:
Pierangelo Masarati 2003-04-12 01:17:05 +00:00
parent 99ac2cb422
commit ab47effcfd
9 changed files with 41 additions and 47 deletions

View File

@ -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

View File

@ -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 ) {

View File

@ -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 ) {

View File

@ -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 );

View File

@ -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 ) {
if ( !at || at->at_oid == NULL ) {
return 1;
}
if ( 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",

View File

@ -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 );

View File

@ -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;

View File

@ -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

View File

@ -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 ) {