1 /* abandon.c - decode and handle an ldap abandon operation */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 * Copyright (c) 1995 Regents of the University of Michigan.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms are permitted
13 * provided that this notice is preserved and that due credit is given
14 * to the University of Michigan at Ann Arbor. The name of the University
15 * may not be used to endorse or promote products derived from this
16 * software without specific prior written permission. This software
17 * is provided ``as is'' without express or implied warranty.
23 #include <ac/socket.h>
38 LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY, "conn: %d do_abandon\n",
41 Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 );
45 * Parse the abandon request. It looks like this:
47 * AbandonRequest := MessageID
50 if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
52 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
53 "conn: %d do_abandon: ber_scanf failed\n",
56 Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 );
58 send_ldap_disconnect( conn, op,
59 LDAP_PROTOCOL_ERROR, "decoding error" );
63 if( (rc = get_ctrls( conn, op, 0 )) != LDAP_SUCCESS ) {
64 Debug( LDAP_DEBUG_ANY, "do_abandon: get_ctrls failed\n", 0, 0 ,0 );
69 LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
70 "do_abandon: conn: %d id=%ld\n", conn->c_connid, (long) id ));
72 Debug( LDAP_DEBUG_ARGS, "do_abandon: id=%ld\n", (long) id, 0 ,0 );
77 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
78 "do_abandon: conn: %d bad msgid %ld\n", conn->c_connid, (long) id ));
80 Debug( LDAP_DEBUG_ANY,
81 "do_abandon: bad msgid %ld\n", (long) id, 0, 0 );
86 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
88 * find the operation being abandoned and set the o_abandon
89 * flag. It's up to the backend to periodically check this
90 * flag and abort the operation at a convenient time.
93 LDAP_STAILQ_FOREACH( o, &conn->c_ops, o_next ) {
94 if ( o->o_msgid == id ) {
95 ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
97 ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
102 LDAP_STAILQ_FOREACH( o, &conn->c_pending_ops, o_next ) {
103 if ( o->o_msgid == id ) {
104 LDAP_STAILQ_REMOVE( &conn->c_pending_ops, o, slap_op, o_next );
111 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
114 LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
115 "do_abandon: conn: %d op=%ld %sfound\n",
116 conn->c_connid, (long)id, o ? "" : "not " ));
118 Debug( LDAP_DEBUG_TRACE, "do_abandon: op=%ld %sfound\n",
119 (long) id, o ? "" : "not ", 0 );