From: Ondrej Kuznik Date: Wed, 8 Feb 2012 13:18:29 +0000 (+0100) Subject: ITS#7182 Maintain the operation counts. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=be9585d0ed805f01772204ce407985223ec8e2b9;p=openldap ITS#7182 Maintain the operation counts. Currently ldap_back_default_rebind cannot access the ldapinfo structure. Being a configurable callback, not letting it monitor when a change might be disruptive feels safer. --- diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index 513db86165..cb24052321 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -113,6 +113,10 @@ retry: } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_ADD ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + cleanup: (void)ldap_back_controls_free( op, rs, &ctrls ); diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 5be6976a54..03c54e473f 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -275,6 +275,10 @@ retry:; } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_BIND ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + ldap_back_controls_free( op, rs, &ctrls ); if ( rc == LDAP_SUCCESS ) { @@ -1461,6 +1465,10 @@ retry_lock:; LDAP_SASL_QUIET, lutil_sasl_interact, defaults ); + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_BIND ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + lutil_sasl_freedefs( defaults ); switch ( rs->sr_err ) { @@ -1510,6 +1518,10 @@ retry:; LDAP_SASL_SIMPLE, &lc->lc_cred, NULL, NULL, &msgid ); + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_BIND ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + if ( rs->sr_err == LDAP_SERVER_DOWN ) { if ( retries != LDAP_BACK_RETRY_NEVER ) { if ( dolock ) { @@ -1634,6 +1646,8 @@ ldap_back_default_rebind( LDAP *ld, LDAP_CONST char *url, ber_tag_t request, #endif /* HAVE_TLS */ /* FIXME: add checks on the URL/identity? */ + /* TODO: would like to count this bind operation for monitoring + * too, but where do we get the ldapinfo_t? */ return ldap_sasl_bind_s( ld, BER_BVISNULL( &lc->lc_cred ) ? "" : lc->lc_bound_ndn.bv_val, @@ -2323,6 +2337,10 @@ ldap_back_proxy_authz_bind( } } while ( rs->sr_err == LDAP_SASL_BIND_IN_PROGRESS ); + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_BIND ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + switch ( rs->sr_err ) { case LDAP_SUCCESS: #ifdef SLAP_AUTH_DN @@ -2430,6 +2448,10 @@ ldap_back_proxy_authz_bind( bindcred, NULL, NULL, &msgid ); rc = ldap_back_op_result( lc, op, rs, msgid, -1, ( sendok | LDAP_BACK_BINDING ) ); + + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_BIND ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); break; default: diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 151edeb8a6..a4747373d9 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -73,6 +73,10 @@ retry: } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_COMPARE ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + cleanup: (void)ldap_back_controls_free( op, rs, &ctrls ); diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c index 4d5c231dbb..eb04d8f88b 100644 --- a/servers/slapd/back-ldap/delete.c +++ b/servers/slapd/back-ldap/delete.c @@ -71,6 +71,10 @@ retry: } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_DELETE ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + cleanup: (void)ldap_back_controls_free( op, rs, &ctrls ); diff --git a/servers/slapd/back-ldap/extended.c b/servers/slapd/back-ldap/extended.c index 574a545c3c..b96ddc0367 100644 --- a/servers/slapd/back-ldap/extended.c +++ b/servers/slapd/back-ldap/extended.c @@ -264,6 +264,10 @@ retry: ldap_back_quarantine( op, rs ); } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_EXTENDED ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + if ( freedn ) { op->o_tmpfree( dn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx ); @@ -377,6 +381,10 @@ retry: ldap_back_quarantine( op, rs ); } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_EXTENDED ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + /* these have to be freed anyway... */ if ( rs->sr_matched ) { free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 7012c227ba..e2dccea0f5 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -120,6 +120,10 @@ retry:; } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_MODIFY ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + cleanup:; (void)ldap_back_controls_free( op, rs, &ctrls ); diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c index 34e38e4356..a4c99fcc53 100644 --- a/servers/slapd/back-ldap/modrdn.c +++ b/servers/slapd/back-ldap/modrdn.c @@ -104,6 +104,10 @@ retry: } } + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_MODRDN ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + cleanup: (void)ldap_back_controls_free( op, rs, &ctrls ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 22aa5c23c2..d2d2080c86 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -236,6 +236,10 @@ retry: tv.tv_sec ? &tv : NULL, op->ors_slimit, op->ors_deref, &msgid ); + ldap_pvt_thread_mutex_lock( &li->li_counter_mutex ); + ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_SEARCH ], 1 ); + ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex ); + if ( rs->sr_err != LDAP_SUCCESS ) { switch ( rs->sr_err ) { case LDAP_SERVER_DOWN: