plug more one-time leaks; rearrange subsystems setup

This commit is contained in:
Pierangelo Masarati 2005-08-08 20:45:10 +00:00
parent b1e4b27388
commit c984c229d6
11 changed files with 185 additions and 81 deletions

View file

@ -251,6 +251,8 @@ typedef struct monitor_subsys_t {
/* initialize entry and subentries */
int ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
/* destroy structure */
int ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms );
/* update existing dynamic entry and subentries */
int ( *mss_update )( Operation *, SlapReply *, Entry * );
/* create new dynamic subentries */

View file

@ -32,6 +32,20 @@
#define MONITOR_LEGACY_CONN
#endif
static int
monitor_subsys_conn_update(
Operation *op,
SlapReply *rs,
Entry *e );
static int
monitor_subsys_conn_create(
Operation *op,
SlapReply *rs,
struct berval *ndn,
Entry *e_parent,
Entry **ep );
int
monitor_subsys_conn_init(
BackendDB *be,
@ -45,6 +59,9 @@ monitor_subsys_conn_init(
assert( be != NULL );
ms->mss_update = monitor_subsys_conn_update;
ms->mss_create = monitor_subsys_conn_create;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi, &ms->mss_ndn, &e_conn ) ) {
@ -170,7 +187,7 @@ monitor_subsys_conn_init(
return( 0 );
}
int
static int
monitor_subsys_conn_update(
Operation *op,
SlapReply *rs,
@ -469,7 +486,7 @@ conn_create(
return SLAP_CB_CONTINUE;
}
int
static int
monitor_subsys_conn_create(
Operation *op,
SlapReply *rs,

View file

@ -54,6 +54,12 @@ static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e );
#define PATH_MAX 4095
#endif /* ! PATH_MAX */
static int
monitor_subsys_database_modify(
Operation *op,
SlapReply *rs,
Entry *e );
static struct restricted_ops_t {
struct berval op;
unsigned int tag;
@ -129,6 +135,8 @@ monitor_subsys_database_init(
assert( be != NULL );
ms->mss_modify = monitor_subsys_database_modify;
mi = ( monitor_info_t * )be->be_private;
ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
@ -545,12 +553,11 @@ value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta )
return LDAP_SUCCESS;
}
int
static int
monitor_subsys_database_modify(
Operation *op,
SlapReply *rs,
Entry *e
)
Entry *e )
{
monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
int rc = LDAP_OTHER;

View file

@ -62,6 +62,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_backend_init,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
@ -72,8 +73,9 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_VOLATILE_CH,
monitor_subsys_conn_init,
monitor_subsys_conn_update,
monitor_subsys_conn_create,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
}, {
SLAPD_MONITOR_DATABASE_NAME,
@ -82,9 +84,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_database_init,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
monitor_subsys_database_modify
NULL /* modify */
}, {
SLAPD_MONITOR_LISTENER_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
@ -92,6 +95,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_listener_init,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
@ -103,9 +107,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_NONE,
monitor_subsys_log_init,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
monitor_subsys_log_modify
NULL, /* modify */
}, {
SLAPD_MONITOR_OPS_NAME,
BER_BVNULL, BER_BVNULL, BER_BVNULL,
@ -113,7 +118,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_ops_init,
monitor_subsys_ops_update,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL, /* modify */
}, {
@ -123,6 +129,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_overlay_init,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL, /* modify */
@ -133,6 +140,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_NONE,
NULL, /* init */
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
@ -143,7 +151,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_sent_init,
monitor_subsys_sent_update,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL, /* modify */
}, {
@ -153,7 +162,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_thread_init,
monitor_subsys_thread_update,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
}, {
@ -163,7 +173,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_time_init,
monitor_subsys_time_update,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL, /* modify */
}, {
@ -173,6 +184,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_NONE,
NULL, /* init */
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
@ -183,7 +195,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
BER_BVNULL },
MONITOR_F_PERSISTENT_CH,
monitor_subsys_rww_init,
monitor_subsys_rww_update,
NULL, /* destroy */
NULL, /* update */
NULL, /* create */
NULL /* modify */
}, { NULL }
@ -1766,6 +1779,10 @@ monitor_back_db_destroy(
int i;
for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
if ( monitor_subsys[ i ]->mss_destroy ) {
monitor_subsys[ i ]->mss_destroy( be, monitor_subsys[ i ] );
}
if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_rdn ) ) {
ch_free( monitor_subsys[ i ]->mss_rdn.bv_val );
}

View file

@ -31,6 +31,17 @@
#include "ldif.h"
#include "back-monitor.h"
static int
monitor_subsys_log_destroy(
BackendDB *be,
monitor_subsys_t *ms );
static int
monitor_subsys_log_modify(
Operation *op,
SlapReply *rs,
Entry *e );
/*
* log mutex
*/
@ -77,6 +88,9 @@ monitor_subsys_log_init(
Entry *e;
int i;
ms->mss_destroy = monitor_subsys_log_destroy;
ms->mss_modify = monitor_subsys_log_modify;
ldap_pvt_thread_mutex_init( &monitor_log_mutex );
mi = ( monitor_info_t * )be->be_private;
@ -118,7 +132,23 @@ monitor_subsys_log_init(
return( 0 );
}
int
static int
monitor_subsys_log_destroy(
BackendDB *be,
monitor_subsys_t *ms )
{
int i;
for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
if ( !BER_BVISNULL( &int_2_level[ i ].n ) ) {
ch_free( int_2_level[ i ].n.bv_val );
}
}
return 0;
}
static int
monitor_subsys_log_modify(
Operation *op,
SlapReply *rs,

View file

@ -45,11 +45,21 @@ struct monitor_ops_t {
{ BER_BVNULL, BER_BVNULL }
};
static int
monitor_subsys_ops_destroy(
BackendDB *be,
monitor_subsys_t *ms );
static int
monitor_subsys_ops_update(
Operation *op,
SlapReply *rs,
Entry *e );
int
monitor_subsys_ops_init(
BackendDB *be,
monitor_subsys_t *ms
)
monitor_subsys_t *ms )
{
monitor_info_t *mi;
@ -61,6 +71,9 @@ monitor_subsys_ops_init(
assert( be != NULL );
ms->mss_destroy = monitor_subsys_ops_destroy;
ms->mss_update = monitor_subsys_ops_update;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi,
@ -152,12 +165,27 @@ monitor_subsys_ops_init(
return( 0 );
}
int
static int
monitor_subsys_ops_destroy(
BackendDB *be,
monitor_subsys_t *ms )
{
int i;
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
if ( !BER_BVISNULL( &monitor_op[ i ].nrdn ) ) {
ch_free( monitor_op[ i ].nrdn.bv_val );
}
}
return 0;
}
static int
monitor_subsys_ops_update(
Operation *op,
SlapReply *rs,
Entry *e
)
Entry *e )
{
monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;

View file

@ -79,18 +79,6 @@ extern int
monitor_subsys_conn_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_conn_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
extern int
monitor_subsys_conn_create LDAP_P((
Operation *op,
SlapReply *rs,
struct berval *ndn,
Entry *e_parent,
Entry **ep ));
/*
* databases
@ -99,11 +87,6 @@ extern int
monitor_subsys_database_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_database_modify LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* entry
@ -194,11 +177,6 @@ extern int
monitor_subsys_log_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_log_modify LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* operations
@ -207,11 +185,6 @@ extern int
monitor_subsys_ops_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_ops_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* overlay
@ -228,11 +201,6 @@ extern int
monitor_subsys_sent_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_sent_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* threads
@ -241,11 +209,6 @@ extern int
monitor_subsys_thread_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_thread_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* time
@ -253,11 +216,6 @@ monitor_subsys_thread_update LDAP_P((
extern int monitor_subsys_time_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_time_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* waiters
@ -266,11 +224,6 @@ extern int
monitor_subsys_rww_init LDAP_P((
BackendDB *be,
monitor_subsys_t *ms ));
extern int
monitor_subsys_rww_update LDAP_P((
Operation *op,
SlapReply *rs,
Entry *e ));
/*
* former external.h

View file

@ -28,6 +28,12 @@
#include "lutil.h"
#include "back-monitor.h"
static int
monitor_subsys_rww_update(
Operation *op,
SlapReply *rs,
Entry *e );
enum {
MONITOR_RWW_READ = 0,
MONITOR_RWW_WRITE,
@ -58,6 +64,8 @@ monitor_subsys_rww_init(
assert( be != NULL );
ms->mss_update = monitor_subsys_rww_update;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi, &ms->mss_ndn, &e_conn ) ) {
@ -139,12 +147,11 @@ monitor_subsys_rww_init(
return( 0 );
}
int
static int
monitor_subsys_rww_update(
Operation *op,
SlapReply *rs,
Entry *e
)
Entry *e )
{
monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private;
Connection *c;

View file

@ -27,6 +27,17 @@
#include "slap.h"
#include "back-monitor.h"
static int
monitor_subsys_sent_destroy(
BackendDB *be,
monitor_subsys_t *ms );
static int
monitor_subsys_sent_update(
Operation *op,
SlapReply *rs,
Entry *e );
enum {
MONITOR_SENT_BYTES = 0,
MONITOR_SENT_PDU,
@ -50,8 +61,7 @@ struct monitor_sent_t {
int
monitor_subsys_sent_init(
BackendDB *be,
monitor_subsys_t *ms
)
monitor_subsys_t *ms )
{
monitor_info_t *mi;
@ -61,6 +71,9 @@ monitor_subsys_sent_init(
assert( be != NULL );
ms->mss_destroy = monitor_subsys_sent_destroy;
ms->mss_update = monitor_subsys_sent_update;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi, &ms->mss_ndn, &e_sent ) ) {
@ -143,7 +156,23 @@ monitor_subsys_sent_init(
return( 0 );
}
int
static int
monitor_subsys_sent_destroy(
BackendDB *be,
monitor_subsys_t *ms )
{
int i;
for ( i = 0; i < MONITOR_SENT_LAST; i++ ) {
if ( !BER_BVISNULL( &monitor_sent[ i ].nrdn ) ) {
ch_free( monitor_sent[ i ].nrdn.bv_val );
}
}
return 0;
}
static int
monitor_subsys_sent_update(
Operation *op,
SlapReply *rs,

View file

@ -29,9 +29,15 @@
#include <ldap_rq.h>
static int
monitor_subsys_thread_update(
Operation *op,
SlapReply *rs,
Entry *e );
/*
* * initializes log subentry
* */
* initializes log subentry
*/
int
monitor_subsys_thread_init(
BackendDB *be,
@ -43,6 +49,8 @@ monitor_subsys_thread_init(
Entry *e, **ep, *e_thread;
static char buf[ BACKMONITOR_BUFSIZE ];
ms->mss_update = monitor_subsys_thread_update;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi, &ms->mss_ndn, &e_thread ) ) {
@ -216,12 +224,11 @@ monitor_subsys_thread_init(
return( 0 );
}
int
static int
monitor_subsys_thread_update(
Operation *op,
SlapReply *rs,
Entry *e
)
Entry *e )
{
monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;
Attribute *a;

View file

@ -31,11 +31,16 @@
#include "proto-slap.h"
#include "back-monitor.h"
static int
monitor_subsys_time_update(
Operation *op,
SlapReply *rs,
Entry *e );
int
monitor_subsys_time_init(
BackendDB *be,
monitor_subsys_t *ms
)
monitor_subsys_t *ms )
{
monitor_info_t *mi;
@ -45,6 +50,8 @@ monitor_subsys_time_init(
assert( be != NULL );
ms->mss_update = monitor_subsys_time_update;
mi = ( monitor_info_t * )be->be_private;
if ( monitor_cache_get( mi,
@ -166,7 +173,7 @@ monitor_subsys_time_init(
return( 0 );
}
int
static int
monitor_subsys_time_update(
Operation *op,
SlapReply *rs,