]> git.sur5r.net Git - openldap/blob - servers/slapd/abandon.c
More header work toward draft-ietf-ldapext-ldap-c-api-01.
[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 extern Backend  *select_backend();
23
24 extern char     *default_referral;
25
26 void
27 do_abandon(
28     Connection  *conn,
29     Operation   *op
30 )
31 {
32         int             id;
33         Backend         *be;
34         Operation       *o;
35
36         Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 );
37
38         /*
39          * Parse the abandon request.  It looks like this:
40          *
41          *      AbandonRequest := MessageID
42          */
43
44         if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
45                 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0 ,0 );
46                 return;
47         }
48
49         Debug( LDAP_DEBUG_ARGS, "do_abandon: id %d\n", id, 0 ,0 );
50
51         /*
52          * find the operation being abandoned and set the o_abandon
53          * flag.  It's up to the backend to periodically check this
54          * flag and abort the operation at a convenient time.
55          */
56
57         pthread_mutex_lock( &conn->c_opsmutex );
58         for ( o = conn->c_ops; o != NULL; o = o->o_next ) {
59                 if ( o->o_msgid == id )
60                         break;
61         }
62
63         if ( o != NULL ) {
64                 pthread_mutex_lock( &o->o_abandonmutex );
65                 o->o_abandon = 1;
66                 pthread_mutex_unlock( &o->o_abandonmutex );
67         } else {
68                 Debug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0,
69                     0 );
70         }
71         pthread_mutex_unlock( &conn->c_opsmutex );
72 }