openldap/servers/slapd/operation.c
Hallvard Furuseth 7e6ad5100c Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking.  Retyped a number of functions, usually
to return void.  Fixed a number of printf format errors.

API changes (in ldap/include):
  Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
  for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.

A number of `extern' declarations are left (some added by protoize), to
be cleaned away later.  Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-15 22:40:11 +00:00

76 lines
1.4 KiB
C

/* operation.c - routines to deal with pending ldap operations */
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
void
op_free( Operation *op )
{
if ( op->o_ber != NULL )
ber_free( op->o_ber, 1 );
if ( op->o_dn != NULL ) {
free( op->o_dn );
}
/* pthread_mutex_destroy( &op->o_abandonmutex ); */
free( (char *) op );
}
Operation *
op_add(
Operation **olist,
BerElement *ber,
unsigned long msgid,
unsigned long tag,
char *dn,
int id,
int connid
)
{
Operation **tmp;
for ( tmp = olist; *tmp != NULL; tmp = &(*tmp)->o_next )
; /* NULL */
*tmp = (Operation *) calloc( 1, sizeof(Operation) );
pthread_mutex_init( &(*tmp)->o_abandonmutex,
pthread_mutexattr_default );
(*tmp)->o_ber = ber;
(*tmp)->o_msgid = msgid;
(*tmp)->o_tag = tag;
(*tmp)->o_abandon = 0;
(*tmp)->o_dn = strdup( dn != NULL ? dn : "" );
pthread_mutex_lock( &currenttime_mutex );
(*tmp)->o_time = currenttime;
pthread_mutex_unlock( &currenttime_mutex );
(*tmp)->o_opid = id;
(*tmp)->o_connid = connid;
(*tmp)->o_next = NULL;
return( *tmp );
}
void
op_delete( Operation **olist, Operation *op )
{
Operation **tmp;
for ( tmp = olist; *tmp != NULL && *tmp != op; tmp = &(*tmp)->o_next )
; /* NULL */
if ( *tmp == NULL ) {
Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
op->o_msgid, 0, 0 );
return;
}
*tmp = (*tmp)->o_next;
op_free( op );
}