From efecf4e121a8f3bd2e943f7dac295b644eb1593a Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 11 Apr 2002 08:03:40 +0000 Subject: [PATCH] ITS#1733 eliminate o_abandonmutex --- servers/slapd/abandon.c | 2 -- servers/slapd/back-bdb/search.c | 7 +------ servers/slapd/back-ldbm/modify.c | 5 +---- servers/slapd/back-ldbm/modrdn.c | 6 ------ servers/slapd/back-ldbm/search.c | 5 ----- servers/slapd/back-meta/search.c | 2 -- servers/slapd/back-monitor/log.c | 2 -- servers/slapd/back-passwd/search.c | 3 --- servers/slapd/back-shell/abandon.c | 1 - servers/slapd/back-sql/search.c | 3 --- servers/slapd/backend.c | 6 +----- servers/slapd/backglue.c | 7 ++----- servers/slapd/connection.c | 3 --- servers/slapd/daemon.c | 1 - servers/slapd/main.c | 1 - servers/slapd/operation.c | 4 ---- servers/slapd/referral.c | 1 - servers/slapd/result.c | 1 - servers/slapd/saslauthz.c | 6 ------ servers/slapd/slap.h | 4 ++-- 20 files changed, 7 insertions(+), 63 deletions(-) diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index cc3cc8cc9e..b092d124f3 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -92,9 +92,7 @@ do_abandon( LDAP_STAILQ_FOREACH( o, &conn->c_ops, o_next ) { if ( o->o_msgid == id ) { - ldap_pvt_thread_mutex_lock( &o->o_abandonmutex ); o->o_abandon = 1; - ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex ); goto done; } } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index af5048a4c2..ed11d5f03c 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -44,7 +44,6 @@ bdb_search( int attrsonly ) { struct bdb_info *bdb = (struct bdb_info *) be->be_private; - int abandon; int rc; const char *text = NULL; time_t stoptime; @@ -299,11 +298,7 @@ bdb_search( int scopeok = 0; /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); - abandon = op->o_abandon; - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - - if ( abandon ) { + if ( op->o_abandon ) { rc = 0; goto done; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 6948d2ffd8..2dfb9be680 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -207,10 +207,7 @@ int ldbm_modify_internal( } /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); - rc = op->o_abandon; - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - if ( rc ) { + if ( op->o_abandon ) { rc = SLAPD_ABANDON; goto exit; } diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index eb5ec10b2e..59aee6894c 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -468,13 +468,10 @@ ldbm_back_modrdn( #endif /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto return_results; } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); if ( ( rc_id = dn2id ( be, &new_ndn, &id ) ) || id != NOID ) { /* if (rc_id) something bad happened to ldbm cache */ send_ldap_result( conn, op, @@ -708,12 +705,9 @@ ldbm_back_modrdn( /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto return_results; } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* delete old one */ if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) { diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index c61b921ac6..a82ffe7f90 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -295,16 +295,11 @@ searchit: int scopeok = 0; /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); - if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); rc = 0; goto done; } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - /* check time limit */ if ( tlimit != -1 && slap_get_time() > stoptime ) { send_search_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 98754a69e3..49edc7a8ad 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -406,9 +406,7 @@ meta_back_search( int ab, gotit = 0; /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); ab = op->o_abandon; - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; lsc++, i++ ) { if ( lsc[ 0 ]->candidate != META_CANDIDATE ) { diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 2a74e1354a..ab379e9222 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -196,9 +196,7 @@ monitor_subsys_log_modify( #if 0 /* need op */ /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); rc = SLAPD_ABANDON; goto cleanup; diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index e88e05030b..2cdeb4c9cf 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -132,13 +132,10 @@ passwd_back_search( for ( pw = getpwent(); pw != NULL; pw = getpwent() ) { /* check for abandon */ - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); endpwent(); return( -1 ); } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check time limit */ if ( slap_get_time() > stoptime ) { diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index dd552a7174..2eccb51f12 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -9,7 +9,6 @@ #include -#include #include #include diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index cf68f8c128..2dca484832 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -584,13 +584,10 @@ int backsql_search(BackendDB *be,Connection *conn,Operation *op, for(eid=srch_info.id_list;eid!=NULL;eid=eid->next) { /* check for abandon */ - ldap_pvt_thread_mutex_lock(&op->o_abandonmutex); if (op->o_abandon) { - ldap_pvt_thread_mutex_unlock(&op->o_abandonmutex); break; } - ldap_pvt_thread_mutex_unlock(&op->o_abandonmutex); /* check time limit */ if ( tlimit != -1 && slap_get_time() > stoptime) diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index b010528dde..1fbeecde21 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -993,12 +993,8 @@ backend_group( ) { GroupAssertion *g; - int i; - ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); - i = op->o_abandon; - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - if (i) return SLAPD_ABANDON; + if ( op->o_abandon ) return SLAPD_ABANDON; if ( !dn_match( &target->e_nname, gr_ndn ) ) { /* we won't attempt to send it to a different backend */ diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 9b1a445325..0eccc8b8ac 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -349,14 +349,11 @@ glue_back_search ( break; } } + rc = 0; /* * check for abandon */ - ldap_pvt_thread_mutex_lock (&op->o_abandonmutex); - rc = op->o_abandon; - ldap_pvt_thread_mutex_unlock (&op->o_abandonmutex); - if (rc) { - rc = 0; + if (op->o_abandon) { goto done; } be = gi->n[i].be; diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 6e1219ddba..41828b6aca 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -740,9 +739,7 @@ static void connection_abandon( Connection *c ) Operation *o; LDAP_STAILQ_FOREACH(o, &c->c_ops, o_next) { - ldap_pvt_thread_mutex_lock( &o->o_abandonmutex ); o->o_abandon = 1; - ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex ); } /* remove pending operations */ diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 5276f7fddd..2ab0fa769f 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 686d9cfa35..fa1bb4916d 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -7,7 +7,6 @@ #include -#include #include #include #include diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index d4473c2643..49c1a7b58c 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -36,8 +36,6 @@ slap_op_free( Operation *op ) ldap_controls_free( op->o_ctrls ); } - ldap_pvt_thread_mutex_destroy( &op->o_abandonmutex ); - free( (char *) op ); } @@ -53,8 +51,6 @@ slap_op_alloc( op = (Operation *) ch_calloc( 1, sizeof(Operation) ); - ldap_pvt_thread_mutex_init( &op->o_abandonmutex ); - op->o_ber = ber; op->o_msgid = msgid; op->o_tag = tag; diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 1293c32a35..d3caa3ffd4 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/servers/slapd/result.c b/servers/slapd/result.c index c48c9a5301..8c96ff0239 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 5b78f4dd37..2f9ee9b74a 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -394,7 +394,6 @@ void slap_sasl2dn( struct berval *saslname, struct berval *dn ) goto FINISHED; suffix_alias( be, &searchbase ); - ldap_pvt_thread_mutex_init( &op.o_abandonmutex ); op.o_tag = LDAP_REQ_SEARCH; op.o_protocol = LDAP_VERSION3; op.o_ndn = *saslname; @@ -405,8 +404,6 @@ void slap_sasl2dn( struct berval *saslname, struct berval *dn ) scope, /*deref=*/1, /*sizelimit=*/1, /*time=*/0, filter, /*fstr=*/NULL, /*attrs=*/NULL, /*attrsonly=*/0 ); - ldap_pvt_thread_mutex_destroy( &op.o_abandonmutex ); - FINISHED: if( searchbase.bv_len ) ch_free( searchbase.bv_val ); if( filter ) filter_free( filter ); @@ -513,7 +510,6 @@ int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval sm.match = 0; cb.sc_private = &sm; - ldap_pvt_thread_mutex_init( &op.o_abandonmutex ); op.o_tag = LDAP_REQ_SEARCH; op.o_protocol = LDAP_VERSION3; op.o_ndn = *authc; @@ -524,8 +520,6 @@ int slap_sasl_match( struct berval *rule, struct berval *assertDN, struct berval scope, /*deref=*/1, /*sizelimit=*/0, /*time=*/0, filter, /*fstr=*/NULL, /*attrs=*/NULL, /*attrsonly=*/0 ); - ldap_pvt_thread_mutex_destroy( &op.o_abandonmutex ); - if (sm.match) rc = LDAP_SUCCESS; else diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index c965f984d3..ce76b301bc 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1442,8 +1443,7 @@ typedef struct slap_op { ldap_pvt_thread_t o_tid; /* thread handling this op */ - ldap_pvt_thread_mutex_t o_abandonmutex; /* protects o_abandon */ - char o_abandon; /* abandon flag */ + volatile sig_atomic_t o_abandon; /* abandon flag */ #define SLAP_NO_CONTROL 0 #define SLAP_NONCRITICAL_CONTROL 1 -- 2.39.5