]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/cancel.c
cleanup bind
[openldap] / servers / slapd / cancel.c
index 96bd7300b51159797e490bb667f7c7b7fa25bdbe..0fcce20d6991cff670ec92f99b61b7950ec06a98 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /* cancel.c - LDAP cancel extended operation */
 /*
  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
 
 #include "slap.h"
 
+#ifdef LDAP_EXOP_X_CANCEL
+
 #include <lber_pvt.h>
 #include <lutil.h>
 
 int cancel_extop(
        Connection *conn,
        Operation *op,
-       const char *reqoid,
+       struct berval *reqoid,
        struct berval *reqdata,
        char **rspoid,
        struct berval **rspdata,
@@ -34,9 +37,10 @@ int cancel_extop(
        int found = 0;
        int opid;
        BerElement *ber;
+       int i;
 
        assert( reqoid != NULL );
-       assert( strcmp( LDAP_EXOP_X_CANCEL, reqoid ) == 0 );
+       assert( ber_bvcmp( &slap_EXOP_CANCEL, reqoid ) == 0 );
 
        if ( reqdata == NULL ) {
                *text = "no message ID supplied";
@@ -72,8 +76,7 @@ int cancel_extop(
        }
        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
 
-       if ( found )
-               return LDAP_SUCCESS;
+       if ( found ) return LDAP_SUCCESS;
 
        found = 0;
        ldap_pvt_thread_mutex_lock( &conn->c_mutex );
@@ -85,30 +88,49 @@ int cancel_extop(
        }
 
        if ( !found ) {
-               *text = "message ID not found";
+#ifdef LDAP_SYNC
+               for ( i = 0; i < nbackends; i++ ) {
+                       Backend *be = &backends[i];
+                       if( !be->be_cancel ) continue;
+
+                       ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+
+                       if ( be->be_cancel( be, conn, op, opid ) == LDAP_SUCCESS ) {
+                               return LDAP_SUCCESS;
+                       } else {
+                               *text = "message ID not found";
+                               return LDAP_NO_SUCH_OPERATION;
+                       }
+               }
+#else
                ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
-               return LDAP_NO_SUCH_OPERATION;
+               *text = "message ID not found";
+               return LDAP_NO_SUCH_OPERATION;
+#endif
        }
 
-       if ( op->o_cancel != LDAP_CANCEL_NONE ) {
-               *text = "message ID already being cancelled";
+       if ( op->o_cancel != SLAP_CANCEL_NONE ) {
                ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+               *text = "message ID already being cancelled";
                return LDAP_PROTOCOL_ERROR;
        }
 
-       op->o_cancel = LDAP_CANCEL_REQ;
+       op->o_cancel = SLAP_CANCEL_REQ;
        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
 
-       while ( op->o_cancel == LDAP_CANCEL_REQ ) {
+       while ( op->o_cancel == SLAP_CANCEL_REQ ) {
                ldap_pvt_thread_yield();
        }
 
-       if ( op->o_cancel == LDAP_CANCEL_ACK ) {
+       if ( op->o_cancel == SLAP_CANCEL_ACK ) {
                rc = LDAP_SUCCESS;
        } else {
                rc = op->o_cancel;
-               op->o_cancel = LDAP_CANCEL_NOTDONE;
        }
 
+       op->o_cancel = SLAP_CANCEL_DONE;
+
        return rc;
 }
+
+#endif /* LDAP_EXOP_X_CANCEL */