1 /* abandon.c - decode and handle an ldap abandon operation */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
30 #include <ac/socket.h>
35 do_abandon( Operation *op, SlapReply *rs )
42 LDAP_LOG( OPERATION, ENTRY, "conn: %d do_abandon\n", op->o_connid, 0, 0);
44 Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 );
48 * Parse the abandon request. It looks like this:
50 * AbandonRequest := MessageID
53 if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
55 LDAP_LOG( OPERATION, ERR,
56 "conn: %d do_abandon: ber_scanf failed\n", op->o_connid, 0, 0 );
58 Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 );
60 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
61 return SLAPD_DISCONNECT;
64 if( get_ctrls( op, rs, 0 ) != LDAP_SUCCESS ) {
65 Debug( LDAP_DEBUG_ANY, "do_abandon: get_ctrls failed\n", 0, 0 ,0 );
70 LDAP_LOG( OPERATION, ARGS, "do_abandon: conn: %d id=%ld\n",
71 op->o_connid, (long) id, 0 );
73 Debug( LDAP_DEBUG_ARGS, "do_abandon: id=%ld\n", (long) id, 0 ,0 );
78 LDAP_LOG( OPERATION, ERR,
79 "do_abandon: conn: %d bad msgid %ld\n",
80 op->o_connid, (long) id, 0 );
82 Debug( LDAP_DEBUG_ANY,
83 "do_abandon: bad msgid %ld\n", (long) id, 0, 0 );
88 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
90 * find the operation being abandoned and set the o_abandon
91 * flag. It's up to the backend to periodically check this
92 * flag and abort the operation at a convenient time.
95 LDAP_STAILQ_FOREACH( o, &op->o_conn->c_ops, o_next ) {
96 if ( o->o_msgid == id ) {
102 LDAP_STAILQ_FOREACH( o, &op->o_conn->c_pending_ops, o_next ) {
103 if ( o->o_msgid == id ) {
104 LDAP_STAILQ_REMOVE( &op->o_conn->c_pending_ops,
105 o, slap_op, o_next );
106 LDAP_STAILQ_NEXT(o, o_next) = NULL;
107 op->o_conn->c_n_ops_pending--;
116 if ( frontendDB->be_abandon ) {
117 op->o_bd = frontendDB;
118 frontendDB->be_abandon( op, rs );
121 for ( i = 0; i < nbackends; i++ ) {
122 op->o_bd = &backends[i];
123 if( op->o_bd->be_abandon ) op->o_bd->be_abandon( op, rs );
126 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
129 LDAP_LOG( OPERATION, ENTRY,
130 "do_abandon: conn: %d op=%ld %sfound\n",
131 op->o_connid, (long)id, o ? "" : "not " );
133 Debug( LDAP_DEBUG_TRACE, "do_abandon: op=%ld %sfound\n",
134 (long) id, o ? "" : "not ", 0 );