Misc code cleanup

This commit is contained in:
Kurt Zeilenga 2003-12-29 22:25:43 +00:00
parent 3c00b4448a
commit fcad25da47
8 changed files with 58 additions and 76 deletions

View File

@ -29,8 +29,6 @@
#include "ldap-int.h" #include "ldap-int.h"
#include "ldap_log.h" #include "ldap_log.h"
#ifdef LDAP_EXOP_X_CANCEL
int int
ldap_cancel( ldap_cancel(
LDAP *ld, LDAP *ld,
@ -72,4 +70,3 @@ ldap_cancel_s(
return rc; return rc;
} }
#endif /* LDAP_EXOP_X_CANCEL */

View File

@ -108,12 +108,10 @@ static struct ldaperror ldap_builtin_errlist[] = {
{LDAP_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required")}, {LDAP_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required")},
{LDAP_ASSERTION_FAILED, N_("Assertion Failed")}, {LDAP_ASSERTION_FAILED, N_("Assertion Failed")},
#ifdef LDAP_EXOP_X_CANCEL
{LDAP_CANCELLED, N_("Cancelled")}, {LDAP_CANCELLED, N_("Cancelled")},
{LDAP_NO_SUCH_OPERATION, N_("No Operation to Cancel")}, {LDAP_NO_SUCH_OPERATION, N_("No Operation to Cancel")},
{LDAP_TOO_LATE, N_("Too Late to Cancel")}, {LDAP_TOO_LATE, N_("Too Late to Cancel")},
{LDAP_CANNOT_CANCEL, N_("Cannot Cancel")}, {LDAP_CANNOT_CANCEL, N_("Cannot Cancel")},
#endif
{0, NULL} {0, NULL}
}; };

View File

@ -386,7 +386,8 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
ID lastid = NOID; ID lastid = NOID;
AttributeName *attrs; AttributeName *attrs;
Filter contextcsnand, contextcsnle, cookief, csnfnot, csnfeq, csnfand, csnfge; Filter contextcsnand, contextcsnle, cookief, csnfnot,
csnfeq, csnfand, csnfge;
AttributeAssertion aa_ge, aa_eq, aa_le; AttributeAssertion aa_ge, aa_eq, aa_le;
int entry_count = 0; int entry_count = 0;
struct berval *search_context_csn = NULL; struct berval *search_context_csn = NULL;
@ -440,8 +441,10 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link ); LDAP_LIST_INSERT_HEAD( &bdb->bi_psearch_list, sop, o_ps_link );
ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock ); ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
} else if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST } else if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST
&& sop->o_sync_slog_size >= 0 ) { && sop->o_sync_slog_size >= 0 )
{
ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock ); ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) { LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
if ( ps_list->o_sync_slog_size >= 0 ) { if ( ps_list->o_sync_slog_size >= 0 ) {
@ -504,11 +507,13 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
/* Sync control overrides manageDSAit */ /* Sync control overrides manageDSAit */
if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH ) { if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
if ( manageDSAit == SLAP_NO_CONTROL ) if ( manageDSAit == SLAP_NO_CONTROL ) {
manageDSAit = SLAP_CRITICAL_CONTROL; manageDSAit = SLAP_CRITICAL_CONTROL;
}
} else if ( IS_PSEARCH ) { } else if ( IS_PSEARCH ) {
if ( manageDSAit == SLAP_NO_CONTROL ) if ( manageDSAit == SLAP_NO_CONTROL ) {
manageDSAit = SLAP_CRITICAL_CONTROL; manageDSAit = SLAP_CRITICAL_CONTROL;
}
} }
rs->sr_err = LOCK_ID (bdb->bi_dbenv, &locker ); rs->sr_err = LOCK_ID (bdb->bi_dbenv, &locker );
@ -534,9 +539,11 @@ dn2entry_retry:
switch(rs->sr_err) { switch(rs->sr_err) {
case DB_NOTFOUND: case DB_NOTFOUND:
matched = ei->bei_e; break; matched = ei->bei_e;
break;
case 0: case 0:
e = ei->bei_e; break; e = ei->bei_e;
break;
case LDAP_BUSY: case LDAP_BUSY:
send_ldap_error( sop, rs, LDAP_BUSY, "ldap server busy" ); send_ldap_error( sop, rs, LDAP_BUSY, "ldap server busy" );
LOCK_ID_FREE (bdb->bi_dbenv, locker ); LOCK_ID_FREE (bdb->bi_dbenv, locker );
@ -736,16 +743,19 @@ dn2entry_retry:
e = NULL; e = NULL;
if ( !IS_PSEARCH ) { if ( !IS_PSEARCH ) {
rs->sr_err = bdb_get_commit_csn( sop, rs, &search_context_csn, locker, &ctxcsn_lock ); rs->sr_err = bdb_get_commit_csn( sop, rs, &search_context_csn,
locker, &ctxcsn_lock );
if ( rs->sr_err != LDAP_SUCCESS ) { if ( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_error( sop, rs, rs->sr_err, "error in csn management in search" ); send_ldap_error( sop, rs, rs->sr_err,
"error in csn management in search" );
goto done; goto done;
} }
if ( sop->o_sync_mode != SLAP_SYNC_NONE && sop->o_sync_state.ctxcsn && if ( sop->o_sync_mode != SLAP_SYNC_NONE &&
sop->o_sync_state.ctxcsn->bv_val && sop->o_sync_state.ctxcsn &&
ber_bvcmp( &sop->o_sync_state.ctxcsn[0], search_context_csn ) == 0 ) sop->o_sync_state.ctxcsn->bv_val &&
ber_bvcmp( &sop->o_sync_state.ctxcsn[0], search_context_csn ) == 0 )
{ {
bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock ); bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock );
goto nochange; goto nochange;
@ -761,7 +771,8 @@ dn2entry_retry:
} else { } else {
BDB_IDL_ZERO( candidates ); BDB_IDL_ZERO( candidates );
BDB_IDL_ZERO( scopes ); BDB_IDL_ZERO( scopes );
rs->sr_err = search_candidates( op, sop, rs, &base, locker, candidates, scopes ); rs->sr_err = search_candidates( op, sop, rs, &base,
locker, candidates, scopes );
} }
if ( !IS_PSEARCH ) { if ( !IS_PSEARCH ) {
@ -852,9 +863,8 @@ dn2entry_retry:
goto loop_begin; goto loop_begin;
} }
if ( (sop->o_sync_mode & SLAP_SYNC_REFRESH) || IS_PSEARCH ) if ( (sop->o_sync_mode & SLAP_SYNC_REFRESH) || IS_PSEARCH ) {
{ int match;
int match;
cookief.f_choice = LDAP_FILTER_AND; cookief.f_choice = LDAP_FILTER_AND;
cookief.f_and = &csnfnot; cookief.f_and = &csnfnot;
@ -901,7 +911,8 @@ dn2entry_retry:
mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering; mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering;
if ( sop->o_sync_state.ctxcsn && if ( sop->o_sync_state.ctxcsn &&
sop->o_sync_state.ctxcsn->bv_val != NULL ) { sop->o_sync_state.ctxcsn->bv_val != NULL )
{
value_match( &match, slap_schema.si_ad_entryCSN, mr, value_match( &match, slap_schema.si_ad_entryCSN, mr,
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
&sop->o_sync_state.ctxcsn[0], search_context_csn, &sop->o_sync_state.ctxcsn[0], search_context_csn,
@ -931,7 +942,6 @@ loop_begin:
goto done; goto done;
} }
#ifdef LDAP_EXOP_X_CANCEL
if ( sop->o_cancel ) { if ( sop->o_cancel ) {
assert( sop->o_cancel == SLAP_CANCEL_REQ ); assert( sop->o_cancel == SLAP_CANCEL_REQ );
rs->sr_err = LDAP_CANCELLED; rs->sr_err = LDAP_CANCELLED;
@ -940,7 +950,6 @@ loop_begin:
rs->sr_err = LDAP_SUCCESS; rs->sr_err = LDAP_SUCCESS;
goto done; goto done;
} }
#endif
/* check time limit */ /* check time limit */
if ( sop->oq_search.rs_tlimit != -1 && slap_get_time() > stoptime ) { if ( sop->oq_search.rs_tlimit != -1 && slap_get_time() > stoptime ) {
@ -998,9 +1007,11 @@ id2entry_retry:
rs->sr_entry = e; rs->sr_entry = e;
#ifdef BDB_SUBENTRIES #ifdef BDB_SUBENTRIES
/* FIXME: send all but syncrepl /* FIXME: send all but syncrepl */
if ( !is_sync_protocol( sop ) ) { #if 0
*/ if ( !is_sync_protocol( sop ) )
#endif
{
if ( is_entry_subentry( e ) ) { if ( is_entry_subentry( e ) ) {
if( sop->oq_search.rs_scope != LDAP_SCOPE_BASE ) { if( sop->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
if(!get_subentries_visibility( sop )) { if(!get_subentries_visibility( sop )) {
@ -1019,10 +1030,8 @@ id2entry_retry:
/* only subentries are visible */ /* only subentries are visible */
goto loop_continue; goto loop_continue;
} }
/*
} }
*/ #endif /* BDB_SUBENTRIES */
#endif
/* Does this candidate actually satisfy the search scope? /* Does this candidate actually satisfy the search scope?
* *
@ -1036,23 +1045,24 @@ id2entry_retry:
switch( sop->ors_scope ) { switch( sop->ors_scope ) {
case LDAP_SCOPE_BASE: case LDAP_SCOPE_BASE:
/* This is always true, yes? */ /* This is always true, yes? */
if ( id == base.e_id ) if ( id == base.e_id ) scopeok = 1;
scopeok = 1;
break; break;
case LDAP_SCOPE_ONELEVEL: case LDAP_SCOPE_ONELEVEL:
if ( ei->bei_parent->bei_id == base.e_id ) if ( ei->bei_parent->bei_id == base.e_id ) scopeok = 1;
scopeok = 1;
break; break;
case LDAP_SCOPE_SUBTREE:
{ EntryInfo *tmp; case LDAP_SCOPE_SUBTREE: {
EntryInfo *tmp;
for ( tmp = BEI(e); tmp->bei_parent; for ( tmp = BEI(e); tmp->bei_parent;
tmp = tmp->bei_parent ) { tmp = tmp->bei_parent )
{
if ( tmp->bei_id == base.e_id ) { if ( tmp->bei_id == base.e_id ) {
scopeok = 1; scopeok = 1;
break; break;
} }
} } }
break; } break;
} }
#ifdef BDB_ALIASES #ifdef BDB_ALIASES
@ -1062,8 +1072,8 @@ id2entry_retry:
* deref it when finding, return it. * deref it when finding, return it.
*/ */
if ( is_entry_alias(e) && if ( is_entry_alias(e) &&
((sop->ors_deref & LDAP_DEREF_FINDING) ((sop->ors_deref & LDAP_DEREF_FINDING) ||
|| !bvmatch(&e->e_nname, &op->o_req_ndn))) !bvmatch(&e->e_nname, &op->o_req_ndn)))
{ {
goto loop_continue; goto loop_continue;
} }
@ -1079,10 +1089,8 @@ id2entry_retry:
} else { } else {
/* subtree, walk up the tree */ /* subtree, walk up the tree */
EntryInfo *tmp = BEI(e); EntryInfo *tmp = BEI(e);
for (;tmp->bei_parent; for (;tmp->bei_parent; tmp=tmp->bei_parent) {
tmp=tmp->bei_parent) { x = bdb_idl_search( scopes, tmp->bei_id );
x = bdb_idl_search(
scopes, tmp->bei_id );
if ( scopes[x] == tmp->bei_id ) { if ( scopes[x] == tmp->bei_id ) {
scopeok = 1; scopeok = 1;
break; break;
@ -1176,7 +1184,8 @@ id2entry_retry:
if ( rs->sr_err == LDAP_COMPARE_TRUE ) { if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
/* check size limit */ /* check size limit */
if ( --sop->oq_search.rs_slimit == -1 && if ( --sop->oq_search.rs_slimit == -1 &&
sop->o_sync_slog_size == -1 ) { sop->o_sync_slog_size == -1 )
{
if (!IS_PSEARCH) { if (!IS_PSEARCH) {
bdb_cache_return_entry_r( bdb->bi_dbenv, bdb_cache_return_entry_r( bdb->bi_dbenv,
&bdb->bi_cache, e, &lock ); &bdb->bi_cache, e, &lock );
@ -1581,9 +1590,7 @@ static void search_stack_free( void *key, void *data )
ber_memfree_x(data, NULL); ber_memfree_x(data, NULL);
} }
static void *search_stack( static void *search_stack( Operation *op )
Operation *op
)
{ {
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
void *ret = NULL; void *ret = NULL;

View File

@ -904,27 +904,19 @@ backend_check_restrictions(
break; break;
} }
{ if( bvmatch( opdata, &slap_EXOP_START_TLS ) ) {
if( bvmatch( opdata, &slap_EXOP_START_TLS ) ) { session++;
session++; starttls++;
starttls++; break;
break;
}
} }
{ if( bvmatch( opdata, &slap_EXOP_WHOAMI ) ) {
if( bvmatch( opdata, &slap_EXOP_WHOAMI ) ) { break;
break;
}
} }
#ifdef LDAP_EXOP_X_CANCEL if ( bvmatch( opdata, &slap_EXOP_CANCEL ) ) {
{ break;
if ( bvmatch( opdata, &slap_EXOP_CANCEL ) ) {
break;
}
} }
#endif
/* treat everything else as a modify */ /* treat everything else as a modify */
opflag = SLAP_RESTRICT_OP_MODIFY; opflag = SLAP_RESTRICT_OP_MODIFY;

View File

@ -25,8 +25,6 @@
#include "slap.h" #include "slap.h"
#ifdef LDAP_EXOP_X_CANCEL
#include <lber_pvt.h> #include <lber_pvt.h>
#include <lutil.h> #include <lutil.h>
@ -127,5 +125,3 @@ int cancel_extop( Operation *op, SlapReply *rs )
return rc; return rc;
} }
#endif /* LDAP_EXOP_X_CANCEL */

View File

@ -1105,7 +1105,6 @@ operations_error:
#endif /* SLAPD_MONITOR */ #endif /* SLAPD_MONITOR */
ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
#ifdef LDAP_EXOP_X_CANCEL
if ( op->o_cancel == SLAP_CANCEL_REQ ) { if ( op->o_cancel == SLAP_CANCEL_REQ ) {
op->o_cancel = LDAP_TOO_LATE; op->o_cancel = LDAP_TOO_LATE;
} }
@ -1115,7 +1114,6 @@ operations_error:
{ {
ldap_pvt_thread_yield(); ldap_pvt_thread_yield();
} }
#endif
ldap_pvt_thread_mutex_lock( &conn->c_mutex ); ldap_pvt_thread_mutex_lock( &conn->c_mutex );

View File

@ -65,9 +65,7 @@ static SLAP_EXTOP_MAIN_FN whoami_extop;
* just a way to get built-in extops onto the extop list without * just a way to get built-in extops onto the extop list without
* having a separate init routine for each built-in extop. * having a separate init routine for each built-in extop.
*/ */
#ifdef LDAP_EXOP_X_CANCEL
const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_X_CANCEL); const struct berval slap_EXOP_CANCEL = BER_BVC(LDAP_EXOP_X_CANCEL);
#endif
const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_X_WHO_AM_I); const struct berval slap_EXOP_WHOAMI = BER_BVC(LDAP_EXOP_X_WHO_AM_I);
const struct berval slap_EXOP_MODIFY_PASSWD = BER_BVC(LDAP_EXOP_MODIFY_PASSWD); const struct berval slap_EXOP_MODIFY_PASSWD = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS); const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS);
@ -77,9 +75,7 @@ static struct {
slap_mask_t flags; slap_mask_t flags;
SLAP_EXTOP_MAIN_FN *ext_main; SLAP_EXTOP_MAIN_FN *ext_main;
} builtin_extops[] = { } builtin_extops[] = {
#ifdef LDAP_EXOP_X_CANCEL
{ &slap_EXOP_CANCEL, SLAP_EXOP_HIDE, cancel_extop }, { &slap_EXOP_CANCEL, SLAP_EXOP_HIDE, cancel_extop },
#endif
{ &slap_EXOP_WHOAMI, 0, whoami_extop }, { &slap_EXOP_WHOAMI, 0, whoami_extop },
{ &slap_EXOP_MODIFY_PASSWD, 0, passwd_extop }, { &slap_EXOP_MODIFY_PASSWD, 0, passwd_extop },
#ifdef HAVE_TLS #ifdef HAVE_TLS

View File

@ -505,9 +505,7 @@ LDAP_SLAPD_F (Entry *) entry_dup LDAP_P(( Entry *e ));
*/ */
LDAP_SLAPD_F (int) exop_root_dse_info LDAP_P ((Entry *e)); LDAP_SLAPD_F (int) exop_root_dse_info LDAP_P ((Entry *e));
#ifdef LDAP_EXOP_X_CANCEL
LDAP_SLAPD_V( const struct berval ) slap_EXOP_CANCEL; LDAP_SLAPD_V( const struct berval ) slap_EXOP_CANCEL;
#endif
LDAP_SLAPD_V( const struct berval ) slap_EXOP_WHOAMI; LDAP_SLAPD_V( const struct berval ) slap_EXOP_WHOAMI;
LDAP_SLAPD_V( const struct berval ) slap_EXOP_MODIFY_PASSWD; LDAP_SLAPD_V( const struct berval ) slap_EXOP_MODIFY_PASSWD;
LDAP_SLAPD_V( const struct berval ) slap_EXOP_START_TLS; LDAP_SLAPD_V( const struct berval ) slap_EXOP_START_TLS;