]> git.sur5r.net Git - openldap/blob - servers/slapd/abandon.c
Don't try to free NULL idl. Did not cause a problem, though, as
[openldap] / servers / slapd / abandon.c
1 /* abandon.c - decode and handle an ldap abandon operation */
2
3 /*
4  * Copyright (c) 1995 Regents of the University of Michigan.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms are permitted
8  * provided that this notice is preserved and that due credit is given
9  * to the University of Michigan at Ann Arbor. The name of the University
10  * may not be used to endorse or promote products derived from this
11  * software without specific prior written permission. This software
12  * is provided ``as is'' without express or implied warranty.
13  */
14
15 #include "portable.h"
16
17 #include <stdio.h>
18 #include <ac/socket.h>
19
20 #include "slap.h"
21
22 void
23 do_abandon(
24     Connection  *conn,
25     Operation   *op
26 )
27 {
28         int             id;
29         Backend         *be;
30         Operation       *o;
31
32         Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 );
33
34         /*
35          * Parse the abandon request.  It looks like this:
36          *
37          *      AbandonRequest := MessageID
38          */
39
40         if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
41                 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0 ,0 );
42                 return;
43         }
44
45         Debug( LDAP_DEBUG_ARGS, "do_abandon: id %d\n", id, 0 ,0 );
46
47         /*
48          * find the operation being abandoned and set the o_abandon
49          * flag.  It's up to the backend to periodically check this
50          * flag and abort the operation at a convenient time.
51          */
52
53         ldap_pvt_thread_mutex_lock( &conn->c_opsmutex );
54         for ( o = conn->c_ops; o != NULL; o = o->o_next ) {
55                 if ( o->o_msgid == id )
56                         break;
57         }
58
59         if ( o != NULL ) {
60                 ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
61                 o->o_abandon = 1;
62                 ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
63         } else {
64                 Debug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0,
65                     0 );
66         }
67         ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex );
68 }