]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/conn.c
Plug memory leak
[openldap] / servers / slapd / back-monitor / conn.c
index ae877020b70893cc627f6a68177bee27697af5c1..5bbaca74e1bcf43960d501240a5b8f414d841416 100644 (file)
@@ -34,6 +34,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include "lutil.h"
 
 #include "slap.h"
 #include "back-monitor.h"
@@ -59,10 +60,10 @@ monitor_subsys_conn_init(
        if ( monitor_cache_get( mi,
                        &monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn, &e_conn ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_init: "
                        "unable to get entry '%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_init: "
@@ -87,10 +88,10 @@ monitor_subsys_conn_init(
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_init: "
                        "unable to create entry 'cn=Total,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_init: "
@@ -117,10 +118,10 @@ monitor_subsys_conn_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_init: "
                        "unable to add entry 'cn=Total,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_init: "
@@ -145,10 +146,10 @@ monitor_subsys_conn_init(
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_init: "
                        "unable to create entry 'cn=Current,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_init: "
@@ -175,10 +176,10 @@ monitor_subsys_conn_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_init: "
                        "unable to add entry 'cn=Current,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_CONN].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_init: "
@@ -210,12 +211,12 @@ monitor_subsys_conn_update(
        assert( mi );
        assert( e );
        
-       if ( strncasecmp( e->e_ndn, "CN=TOTAL", 
-                               sizeof("CN=TOTAL")-1 ) == 0 ) {
+       if ( strncasecmp( e->e_ndn, "cn=total", 
+                               sizeof("cn=total")-1 ) == 0 ) {
                n = connections_nextid();
 
-       } else if ( strncasecmp( e->e_ndn, "CN=CURRENT", 
-                               sizeof("CN=CURRENT")-1 ) == 0 ) {
+       } else if ( strncasecmp( e->e_ndn, "cn=current", 
+                               sizeof("cn=current")-1 ) == 0 ) {
                Connection      *c;
                int             connindex;
 
@@ -252,9 +253,9 @@ conn_create(
 {
        struct monitorentrypriv *mp;
        struct tm               *ltm;
-       char                    buf[1024];
-       char                    buf2[22];
-       char                    buf3[22];
+       char                    buf[ 1024 ];
+       char                    buf2[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+       char                    buf3[ LDAP_LUTIL_GENTIME_BUFSIZE ];
 
        struct berval           bv[2];
 
@@ -273,12 +274,11 @@ conn_create(
 
        if ( e == NULL) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_conn_create: "
                        "unable to create entry "
                        "'cn=" CONN_CN_PREFIX " %ld,%s' entry\n",
-                       c->c_connid, 
-                       monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val ));
+                       c->c_connid, monitor_subsys[SLAPD_MONITOR_CONN].mss_dn.bv_val, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_conn_create: "
@@ -293,10 +293,10 @@ conn_create(
        ldap_pvt_thread_mutex_lock( &gmtime_mutex );
        
        ltm = gmtime( &c->c_starttime );
-       strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
+       lutil_gentime( buf2, sizeof( buf2 ), ltm );
                        
        ltm = gmtime( &c->c_activitytime );
-       strftime( buf3, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
+       lutil_gentime( buf3, sizeof( buf3 ), ltm );
                        
        ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
 
@@ -322,7 +322,7 @@ conn_create(
                connection_state2str( c->c_conn_state ),
                c->c_sasl_bind_in_progress ? "S" : "",
                
-               c->c_cdn.bv_len ? c->c_cdn.bv_val : SLAPD_ANONYMOUS,
+               c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS,
                
                c->c_listener_url.bv_val,
                c->c_peer_domain.bv_val,