1 /* operation.c - routines to deal with pending ldap operations */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
19 slap_op_free( Operation *op )
21 assert( op->o_next == NULL );
23 if ( op->o_ber != NULL ) {
24 ber_free( op->o_ber, 1 );
26 if ( op->o_dn.bv_val != NULL ) {
27 free( op->o_dn.bv_val );
29 if ( op->o_ndn.bv_val != NULL ) {
30 free( op->o_ndn.bv_val );
32 if ( op->o_authmech != NULL ) {
33 free( op->o_authmech );
35 if ( op->o_ctrls != NULL ) {
36 ldap_controls_free( op->o_ctrls );
39 ldap_pvt_thread_mutex_destroy( &op->o_abandonmutex );
54 op = (Operation *) ch_calloc( 1, sizeof(Operation) );
56 ldap_pvt_thread_mutex_init( &op->o_abandonmutex );
63 op->o_dn.bv_val = NULL;
65 op->o_ndn.bv_val = NULL;
67 op->o_authmech = NULL;
70 op->o_time = slap_get_time();
84 for ( tmp = olist; *tmp != NULL; tmp = &(*tmp)->o_next )
93 slap_op_remove( Operation **olist, Operation *op )
97 for ( tmp = olist; *tmp != NULL && *tmp != op; tmp = &(*tmp)->o_next )
100 if ( *tmp == NULL ) {
102 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
103 "slap_op_remove: can't find op %ld.\n",
104 (long)op->o_msgid ));
106 Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
107 (long) op->o_msgid, 0, 0 );
113 *tmp = (*tmp)->o_next;
119 Operation * slap_op_pop( Operation **olist )
121 Operation *tmp = *olist;
124 *olist = tmp->o_next;