]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/search.c
Plug memory leak
[openldap] / servers / slapd / back-monitor / search.c
index 57d7fa5d0a58f3b789bfea4ec6bb43b3a808565e..2795ee7be1ba50b3c5fe8db7a1dc9242133987cb 100644 (file)
@@ -1,12 +1,9 @@
 /* search.c - monitor backend search function */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
- * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- * 
  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
  * 
  * This work has beed deveolped for the OpenLDAP Foundation 
@@ -51,7 +48,7 @@ monitor_send_children(
        Connection      *conn,
        Operation       *op,
        Filter          *filter,
-       struct berval           **attrs,
+       AttributeName   *attrs,
        int             attrsonly,
        Entry           *e_parent,
        int             sub,
@@ -67,6 +64,7 @@ monitor_send_children(
        mp = ( struct monitorentrypriv * )e_parent->e_private;
        e = mp->mp_children;
 
+       e_ch = NULL;
        if ( MONITOR_HAS_VOLATILE_CH( mp ) ) {
                monitor_entry_create( mi, NULL, e_parent, &e_ch );
        }
@@ -148,26 +146,26 @@ monitor_back_search(
        int             slimit,
        int             tlimit,
        Filter          *filter,
-       const char      *filterstr,
-       struct berval           **attrs,
+       struct berval   *filterstr,
+       AttributeName   *attrs,
        int             attrsonly 
 )
 {
        struct monitorinfo      *mi = (struct monitorinfo *) be->be_private;
-       int             rc;
+       int             rc = LDAP_SUCCESS;
        Entry           *e, *matched = NULL;
        int             nentries = 0;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
-                  "monitor_back_search: enter\n" ));
+       LDAP_LOG( BACK_MON, ENTRY,
+                  "monitor_back_search: enter\n", 0, 0, 0 );
 #else
        Debug(LDAP_DEBUG_TRACE, "=> monitor_back_search\n%s%s%s", "", "", "");
 #endif
 
 
        /* get entry with reader lock */
-       monitor_cache_dn2entry( mi, nbase->bv_val, &e, &matched );
+       monitor_cache_dn2entry( mi, nbase, &e, &matched );
        if ( e == NULL ) {
                send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
                        matched ? matched->e_dn : NULL, 
@@ -176,7 +174,7 @@ monitor_back_search(
                        monitor_cache_release( mi, matched );
                }
 
-               return( 0 );
+               return( rc );
        }
 
        nentries = 0;
@@ -189,6 +187,7 @@ monitor_back_search(
                                        attrsonly, NULL );
                        nentries = 1;
                }
+               rc = LDAP_SUCCESS;
                monitor_cache_release( mi, e );
                break;
 
@@ -197,7 +196,7 @@ monitor_back_search(
                                attrs, attrsonly,
                                e, 0, &nentries );
                if ( rc ) {
-                       // error
+                       rc = LDAP_OTHER;
                }               
                
                break;
@@ -215,14 +214,14 @@ monitor_back_search(
                                attrs, attrsonly,
                                e, 1, &nentries );
                if ( rc ) {
-                       // error
+                       rc = LDAP_OTHER;
                }
 
                break;
        }
        
-       send_search_result( conn, op, LDAP_SUCCESS,
+       send_search_result( conn, op, rc,
                        NULL, NULL, NULL, NULL, nentries );
 
-       return( 0 );
+       return( rc == LDAP_SUCCESS ? 0 : 1 );
 }