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