- ldap_pvt_thread_mutex_lock( &conn->c_mutex );
- LDAP_STAILQ_FOREACH( op, &conn->c_pending_ops, o_next ) {
- if ( op->o_msgid == opid ) {
- LDAP_STAILQ_REMOVE( &conn->c_pending_ops, op, slap_op, o_next );
- slap_op_free( op );
- found = 1;
- break;
+ Statslog( LDAP_DEBUG_STATS, "%s CANCEL msg=%d\n",
+ op->o_log_prefix, opid, 0, 0, 0 );
+
+ ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
+ LDAP_STAILQ_FOREACH( o, &op->o_conn->c_pending_ops, o_next ) {
+ if ( o->o_msgid == opid ) {
+ LDAP_STAILQ_REMOVE( &op->o_conn->c_pending_ops, o, slap_op, o_next );
+ LDAP_STAILQ_NEXT(o, o_next) = NULL;
+ op->o_conn->c_n_ops_pending--;
+ slap_op_free( o );
+ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+ return LDAP_SUCCESS;