]> git.sur5r.net Git - openldap/commitdiff
plug more one-time leaks; rearrange subsystems setup
authorPierangelo Masarati <ando@openldap.org>
Mon, 8 Aug 2005 20:45:10 +0000 (20:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 8 Aug 2005 20:45:10 +0000 (20:45 +0000)
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/operation.c
servers/slapd/back-monitor/proto-back-monitor.h
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/sent.c
servers/slapd/back-monitor/thread.c
servers/slapd/back-monitor/time.c

index 15c853c86b6cf0e8a214bfffdaeb8726af3b09c2..e688f943c33950d1434ae96b6f75438da0481d1c 100644 (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 */
index 6f5a187e714f9f00239ed93e2fdf89c5374bf843..b5fcab790ac3d4ed6f185956662a1d7d2ef36937 100644 (file)
 #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,
index 69df414617430dd9fdf96b05b4edb8dfb1983f33..ae234a143b702e1c83ff529d6d5f0e3b396ab62b 100644 (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;
index 4107471099c708ad6f80da1400f6580fc266cec2..b665f9825b9b170d6aa6a091a7e6803d0968257b 100644 (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 );
                        }
index 5be1d2074199f0f3e8cc37c32e3a222d0c61a187..6a390891d463c49949a3e2c02537464bc85c34cf 100644 (file)
 #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,
index 8b8cac45309aa8186bfdd55b18765484295dbfd4..f7aa7c6483309e4ab9773acce631a519a88c3181 100644 (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;
 
index 6de478a1cc26f1113daa1de372f935d6ee619b44..70007135bde55b51884259f3ba63081af0ffd7b5 100644 (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
index 8f6f50ce40a21f65d39618fef291e079feec4121..0edea5d0792aa5967a8535326d145f3be5dafe51 100644 (file)
 #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;
index f4909e3b18f4a085cfc507ad249bb356137695e8..f6c0a9f17fce87498d7ada9a35db5e7023a0da58 100644 (file)
 #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,
index 5d393a8e197d6f55d6c69737535bd8a927b27472..c76acaa86468941669261ff0e7bd336aa0b81ab4 100644 (file)
 
 #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;
index 02037979b5396800e1f37f48516a2dd72e621b1d..61273a6839763d4f10120c274576b6bad75a4d4a 100644 (file)
 #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,