]> git.sur5r.net Git - openldap/blob - servers/slapd/operation.c
cleanup bind
[openldap] / servers / slapd / operation.c
1 /* operation.c - routines to deal with pending ldap operations */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/string.h>
13 #include <ac/socket.h>
14
15 #include "slap.h"
16
17 #ifdef LDAP_SLAPI
18 #include "slapi.h"
19 #endif
20
21
22 void
23 slap_op_free( Operation *op )
24 {
25         assert( LDAP_STAILQ_NEXT(op, o_next) == NULL );
26
27         if ( op->o_ber != NULL ) {
28                 ber_free( op->o_ber, 1 );
29         }
30         if ( op->o_dn.bv_val != NULL ) {
31                 free( op->o_dn.bv_val );
32         }
33         if ( op->o_ndn.bv_val != NULL ) {
34                 free( op->o_ndn.bv_val );
35         }
36         if ( op->o_authmech.bv_val != NULL ) {
37                 free( op->o_authmech.bv_val );
38         }
39         if ( op->o_ctrls != NULL ) {
40                 ldap_controls_free( op->o_ctrls );
41         }
42
43 #ifdef LDAP_CONNECTIONLESS
44         if ( op->o_res_ber != NULL ) {
45                 ber_free( op->o_res_ber, 1 );
46         }
47 #endif
48 #ifdef LDAP_CLIENT_UPDATE
49         if ( op->o_clientupdate_state.bv_val != NULL ) {
50                 free( op->o_clientupdate_state.bv_val );
51         }
52 #endif
53 #ifdef LDAP_SYNC
54         if ( op->o_sync_state.bv_val != NULL ) {
55                 free( op->o_sync_state.bv_val );
56         }
57 #endif
58
59 #if defined( LDAP_SLAPI )
60         if ( op->o_pb != NULL ) {
61                 slapi_pblock_destroy( (Slapi_PBlock *)op->o_pb );
62         }
63 #endif /* defined( LDAP_SLAPI ) */
64
65         free( (char *) op );
66 }
67
68 Operation *
69 slap_op_alloc(
70     BerElement          *ber,
71     ber_int_t   msgid,
72     ber_tag_t   tag,
73     ber_int_t   id
74 )
75 {
76         Operation       *op;
77
78         op = (Operation *) ch_calloc( 1, sizeof(Operation) );
79
80         op->o_ber = ber;
81         op->o_msgid = msgid;
82         op->o_tag = tag;
83
84         op->o_time = slap_get_time();
85         op->o_opid = id;
86 #ifdef LDAP_CONNECTIONLESS
87         op->o_res_ber = NULL;
88 #endif
89
90 #if defined( LDAP_SLAPI )
91         op->o_pb = slapi_pblock_new();
92 #endif /* defined( LDAP_SLAPI ) */
93
94         return( op );
95 }