/* 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
Connection *conn,
Operation *op,
Filter *filter,
- char **attrs,
+ AttributeName *attrs,
int attrsonly,
Entry *e_parent,
int sub,
)
{
struct monitorinfo *mi = (struct monitorinfo *) be->be_private;
- Entry *e, *e_tmp;
+ Entry *e, *e_tmp, *e_ch;
struct monitorentrypriv *mp;
int nentries;
int rc;
mp = ( struct monitorentrypriv * )e_parent->e_private;
e = mp->mp_children;
- if ( e == NULL && MONITOR_HAS_VOLATILE_CH( mp ) ) {
- monitor_entry_create( mi, NULL, e_parent, &e );
- if ( e != NULL) {
- monitor_cache_lock( e );
- }
+ e_ch = NULL;
+ if ( MONITOR_HAS_VOLATILE_CH( mp ) ) {
+ monitor_entry_create( mi, NULL, e_parent, &e_ch );
}
monitor_cache_release( mi, e_parent );
+ /* no volatile entries? */
+ if ( e_ch == NULL ) {
+ /* no persistent entries? return */
+ if ( e == NULL ) {
+ return( 0 );
+ }
+
+ /* volatile entries */
+ } else {
+ /* if no persistent, return only volatile */
+ if ( e == NULL ) {
+ e = e_ch;
+ monitor_cache_lock( e_ch );
+
+ /* else append persistent to volatile */
+ } else {
+ e_tmp = e_ch;
+ do {
+ mp = ( struct monitorentrypriv * )e_tmp->e_private;
+ e_tmp = mp->mp_next;
+
+ if ( e_tmp == NULL ) {
+ mp->mp_next = e;
+ break;
+ }
+ } while ( e_tmp );
+ e = e_ch;
+ }
+ }
+
+ /* return entries */
for ( nentries = *nentriesp; e != NULL; ) {
mp = ( struct monitorentrypriv * )e->e_private;
int
monitor_back_search(
Backend *be,
- Connection *conn,
- Operation *op,
- const char *base,
- const char *nbase,
- int scope,
- int deref,
- int slimit,
- int tlimit,
- Filter *filter,
- const char *filterstr,
- char **attrs,
- int attrsonly
+ Connection *conn,
+ Operation *op,
+ struct berval *base,
+ struct berval *nbase,
+ int scope,
+ int deref,
+ int slimit,
+ int tlimit,
+ Filter *filter,
+ 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
monitor_cache_release( mi, matched );
}
- return( 0 );
+ return( rc );
}
nentries = 0;
attrsonly, NULL );
nentries = 1;
}
+ rc = LDAP_SUCCESS;
monitor_cache_release( mi, e );
break;
attrs, attrsonly,
e, 0, &nentries );
if ( rc ) {
- // error
+ rc = LDAP_OTHER;
}
break;
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 );
}