- 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;
+ 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, Operation, o_next );
+ LDAP_STAILQ_NEXT(o, o_next) = NULL;
+ op->o_conn->c_n_ops_pending--;
+ slap_op_free( o, NULL );
+ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+ return LDAP_SUCCESS;