#define LDAP_CUP_DEFAULT_SEND_COOKIE_INTERVAL 0x01
#endif /* LDAP_CLIENT_UPDATE */
+/* resultCode for Cancel Response */
+#define LDAP_CANCELLED 0x68
+#define LDAP_NO_SUCH_OPERATION 0x69
+#define LDAP_TOO_LATE 0x6a
+#define LDAP_CANNOT_CANCEL 0x6b
+
+#define LDAP_CANCEL_NONE 0x00
+#define LDAP_CANCEL_REQ 0x01
+#define LDAP_CANCEL_ACK 0x02
+#define LDAP_CANCEL_NOTDONE 0x03
+
/*
* This structure represents both ldap messages and ldap responses.
* These are really the same, except in the case of search responses,
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c os-ip.c url.c sortctrl.c vlvctrl.c \
init.c options.c print.c string.c util-int.c schema.c \
- charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c
+ charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
+ cancel.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
controls.lo messages.lo references.lo extended.lo cyrus.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
- charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo
+ charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
+ cancel.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
--- /dev/null
+/*
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+/*
+ * LDAPv3 Cancel Operation Request
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+#include "ldap_log.h"
+
+int
+ldap_cancel(
+ LDAP *ld,
+ int cancelid,
+ LDAPControl **sctrls,
+ LDAPControl **cctrls,
+ int *msgidp )
+{
+ BerElement *cancelidber = NULL;
+ struct berval *cancelidvalp = NULL;
+ int rc;
+
+ cancelidber = ber_alloc_t( LBER_USE_DER );
+ ber_printf( cancelidber, "{i}", cancelid );
+ ber_flatten( cancelidber, &cancelidvalp );
+ rc = ldap_extended_operation( ld, LDAP_EXOP_X_CANCEL,
+ cancelidvalp, sctrls, cctrls, msgidp );
+ ber_free( cancelidber, 1 );
+ return rc;
+}
+
+int
+ldap_cancel_s(
+ LDAP *ld,
+ int cancelid,
+ LDAPControl **sctrls,
+ LDAPControl **cctrls )
+{
+ BerElement *cancelidber = NULL;
+ struct berval *cancelidvalp = NULL;
+ int rc;
+
+ cancelidber = ber_alloc_t( LBER_USE_DER );
+ ber_printf( cancelidber, "{i}", cancelid );
+ ber_flatten( cancelidber, &cancelidvalp );
+ rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_CANCEL,
+ cancelidvalp, sctrls, cctrls, NULL, NULL );
+ ber_free( cancelidber, 1 );
+ return rc;
+}
schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
oidm.c starttls.c index.c sets.c referral.c \
root_dse.c sasl.c module.c suffixalias.c mra.c mods.c \
- limits.c backglue.c operational.c matchedValues.c \
+ limits.c backglue.c operational.c matchedValues.c cancel.c \
$(@PLAT@_SRCS)
OBJS = main.o daemon.o connection.o search.o filter.o add.o cr.o \
schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
oidm.o starttls.o index.o sets.o referral.o \
root_dse.o sasl.o module.o suffixalias.o mra.o mods.o \
- limits.o backglue.o operational.o matchedValues.o \
+ limits.o backglue.o operational.o matchedValues.o cancel.o \
$(@PLAT@_OBJS)
LDAP_INCDIR= ../../include -Islapi
goto done;
}
+ if ( op->o_cancel ) {
+ assert( op->o_cancel == LDAP_CANCEL_REQ );
+ rc = 0;
+ send_search_result( conn, op, LDAP_CANCELLED,
+ NULL, NULL, NULL, NULL, 0 );
+ op->o_cancel = LDAP_CANCEL_ACK;
+ goto done;
+ }
+
/* check time limit */
if ( tlimit != -1 && slap_get_time() > stoptime ) {
send_search_result( conn, op, rc = LDAP_TIMELIMIT_EXCEEDED,
}
}
+ {
+ struct berval bv = BER_BVC( LDAP_EXOP_X_CANCEL );
+ if ( bvmatch( opdata, &bv ) ) {
+ break;
+ }
+ }
+
/* treat everything else as a modify */
opflag = SLAP_RESTRICT_OP_MODIFY;
updateop++;
--- /dev/null
+/* cancel.c - LDAP cancel extended operation */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "slap.h"
+
+#include <lber_pvt.h>
+#include <lutil.h>
+
+int cancel_extop(
+ Connection *conn,
+ Operation *op,
+ const char *reqoid,
+ struct berval *reqdata,
+ char **rspoid,
+ struct berval **rspdata,
+ LDAPControl ***rspctrls,
+ const char **text,
+ BerVarray *refs )
+{
+ Backend *be;
+ int rc;
+ int found = 0;
+ int opid;
+ BerElement *ber;
+
+ assert( reqoid != NULL );
+ assert( strcmp( LDAP_EXOP_X_CANCEL, reqoid ) == 0 );
+
+ if ( reqdata == NULL ) {
+ *text = "no message ID supplied";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ ber = ber_init( reqdata );
+ if ( ber == NULL ) {
+ *text = "internal error";
+ return LDAP_OTHER;
+ }
+
+ if ( ber_scanf( ber, "{i}", &opid ) == LBER_ERROR ) {
+ *text = "message ID parse failed";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ (void) ber_free( ber, 1 );
+
+ if ( opid < 0 ) {
+ *text = "message ID invalid";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ ldap_pvt_thread_mutex_lock( &conn->c_mutex );
+ LDAP_STAILQ_FOREACH( op, &conn->c_pending_ops, o_next ) {
+ if ( op->o_msgid == opid ) {
+ LDAP_STAILQ_REMOVE( &conn->c_pending_ops, op, slap_op, o_next );
+ slap_op_free( op );
+ found = 1;
+ break;
+ }
+ }
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+
+ if ( found )
+ return LDAP_SUCCESS;
+
+ found = 0;
+ ldap_pvt_thread_mutex_lock( &conn->c_mutex );
+ LDAP_STAILQ_FOREACH( op, &conn->c_ops, o_next ) {
+ if ( op->o_msgid == opid ) {
+ found = 1;
+ break;
+ }
+ }
+
+ if ( !found ) {
+ *text = "message ID not found";
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+ return LDAP_NO_SUCH_OPERATION;
+ }
+
+ if ( op->o_cancel != LDAP_CANCEL_NONE ) {
+ *text = "message ID already being cancelled";
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ op->o_cancel = LDAP_CANCEL_REQ;
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+
+ while ( op->o_cancel == LDAP_CANCEL_REQ ) {
+ ldap_pvt_thread_yield();
+ }
+
+ if ( op->o_cancel == LDAP_CANCEL_ACK ) {
+ rc = LDAP_SUCCESS;
+ } else {
+ rc = op->o_cancel;
+ op->o_cancel = LDAP_CANCEL_NOTDONE;
+ }
+
+ return rc;
+}
#endif /* SLAPD_MONITOR */
ldap_pvt_thread_mutex_unlock( &num_ops_mutex );
+ if ( arg->co_op->o_cancel == LDAP_CANCEL_REQ )
+ arg->co_op->o_cancel = LDAP_TOO_LATE;
+
+ while ( arg->co_op->o_cancel != LDAP_CANCEL_NONE &&
+ arg->co_op->o_cancel != LDAP_CANCEL_ACK &&
+ arg->co_op->o_cancel != LDAP_CANCEL_NOTDONE ) {
+ ldap_pvt_thread_yield();
+ }
+
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
conn->c_n_ops_executing--;
#endif
{ BVC(LDAP_EXOP_MODIFY_PASSWD), passwd_extop },
{ BVC(LDAP_EXOP_X_WHO_AM_I), whoami_extop },
+ { BVC(LDAP_EXOP_X_CANCEL), cancel_extop },
{ {0,NULL}, NULL }
};
LDAP_SLAPD_F (struct berval *) get_supported_extop LDAP_P((int index));
+/*
+ * * cancel.c
+ * */
+LDAP_SLAPD_F ( SLAP_EXTOP_MAIN_FN ) cancel_extop;
+
/*
* filter.c
*/
ldap_pvt_thread_t o_tid; /* thread handling this op */
volatile sig_atomic_t o_abandon; /* abandon flag */
+ volatile sig_atomic_t o_cancel; /* cancel flag */
char o_do_not_cache; /* don't cache from this op */
../entry.o ../dn.o ../filter.o ../str2filter.o ../ava.o \
../init.o ../controls.o ../kerberos.o ../passwd.o \
../index.o ../extended.o ../starttls.o ../sets.o ../mra.o \
- ../referral.o ../backglue.o ../oidm.o ../mods.o ../operation.o
+ ../referral.o ../backglue.o ../oidm.o ../mods.o ../operation.o \
+ ../cancel.o
SLAPOBJS = $(SLAPD_OBJS) slapcommon.o mimic.o