Diff for /servers/slapd/back-relay/op.c between versions 1.39 and 1.40

version 1.39, 2009/10/19 21:00:15 version 1.40, 2009/11/02 15:14:39
Line 1 Line 1
 /* op.c - relay backend operations */  /* op.c - relay backend operations */
 /* $OpenLDAP: pkg/ldap/servers/slapd/back-relay/op.c,v 1.38 2009/06/12 21:12:37 hallvard Exp $ */  /* $OpenLDAP: pkg/ldap/servers/slapd/back-relay/op.c,v 1.39 2009/10/19 21:00:15 ando Exp $ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.  /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *   *
  * Copyright 2004-2009 The OpenLDAP Foundation.   * Copyright 2004-2009 The OpenLDAP Foundation.
Line 75  typedef struct relay_callback { Line 75  typedef struct relay_callback {
         BackendDB *rcb_bd;          BackendDB *rcb_bd;
 } relay_callback;  } relay_callback;
   
 int  static int
 relay_back_cleanup_cb( Operation *op, SlapReply *rs )  relay_back_cleanup_cb( Operation *op, SlapReply *rs )
 {  {
         op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd;          op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd;
         return SLAP_CB_CONTINUE;          return SLAP_CB_CONTINUE;
 }  }
   
 int  static int
 relay_back_response_cb( Operation *op, SlapReply *rs )  relay_back_response_cb( Operation *op, SlapReply *rs )
 {  {
         relay_callback  *rcb = (relay_callback *) op->o_callback;          relay_callback  *rcb = (relay_callback *) op->o_callback;
Line 93  relay_back_response_cb( Operation *op, S Line 93  relay_back_response_cb( Operation *op, S
         return SLAP_CB_CONTINUE;          return SLAP_CB_CONTINUE;
 }  }
   
 /* quick hack for ITS#6337: use malloc'ed callback for bind */  #define relay_back_add_cb( rcb, op ) {                          \
 int  
 relay_back_cleanup2_cb( Operation *op, SlapReply *rs )  
 {  
         op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd;  
         op->o_tmpfree( op->o_callback, op->o_tmpmemctx );  
         op->o_callback = NULL;  
         return SLAP_CB_CONTINUE;  
 }  
   
 int  
 relay_back_response2_cb( Operation *op, SlapReply *rs )  
 {  
         relay_callback  *rcb = (relay_callback *) op->o_callback;  
   
         rcb->rcb_sc.sc_cleanup = relay_back_cleanup2_cb;  
         rcb->rcb_bd = op->o_bd;  
         op->o_bd = op->o_callback->sc_private;  
         return SLAP_CB_CONTINUE;  
 }  
   
 #define relay_back_add_cb( rcb, op, bd )                        \  
         {                                                       \  
                 (rcb)->rcb_sc.sc_next = (op)->o_callback;       \                  (rcb)->rcb_sc.sc_next = (op)->o_callback;       \
                 (rcb)->rcb_sc.sc_response = relay_back_response_cb; \                  (rcb)->rcb_sc.sc_response = relay_back_response_cb; \
                 (rcb)->rcb_sc.sc_cleanup = 0;                   \                  (rcb)->rcb_sc.sc_cleanup = 0;                   \
                 (rcb)->rcb_sc.sc_private = (op)->o_bd;          \                  (rcb)->rcb_sc.sc_private = (op)->o_bd;          \
                 (op)->o_callback = (slap_callback *) (rcb);     \                  (op)->o_callback = (slap_callback *) (rcb);     \
         }  }
   
   #define relay_back_remove_cb( rcb, op ) {                       \
                   slap_callback   **sc = &(op)->o_callback;       \
                   for ( ;; sc = &(*sc)->sc_next )                 \
                           if ( *sc == (slap_callback *) (rcb) ) { \
                                   *sc = (*sc)->sc_next; break;    \
                           } else if ( *sc == NULL ) break;        \
   }
   
 /*  /*
  * Select the backend database with the operation's DN.  On failure,   * Select the backend database with the operation's DN.  On failure,
Line 220  relay_back_op( Operation *op, SlapReply Line 206  relay_back_op( Operation *op, SlapReply
         } else if ( (func = (&bd->be_bind)[which]) != 0 ) {          } else if ( (func = (&bd->be_bind)[which]) != 0 ) {
                 relay_callback  rcb;                  relay_callback  rcb;
   
                 if ( which == op_bind ) {                  relay_back_add_cb( &rcb, op );
                         /* quick hack for ITS#6337: use malloc'ed callback for bind */  
                         relay_callback *rcbp = op->o_tmpcalloc( sizeof( relay_callback ), 1, op->o_tmpmemctx );  
                         relay_back_add_cb( rcbp, op, bd );  
                         rcbp->rcb_sc.sc_response = relay_back_response2_cb;  
   
                 } else {  
                         relay_back_add_cb( &rcb, op, bd );  
                 }  
   
                 RELAY_WRAP_OP( op, bd, which, {                  RELAY_WRAP_OP( op, bd, which, {
                         rc = func( op, rs );                          rc = func( op, rs );
                 });                  });
                   relay_back_remove_cb( &rcb, op );
                 if ( op->o_callback == (slap_callback *) &rcb ) {  
                         op->o_callback = op->o_callback->sc_next;  
                 }  
   
         } else if ( fail_mode & RB_OPERR ) {          } else if ( fail_mode & RB_OPERR ) {
                 rs->sr_err = rc;                  rs->sr_err = rc;

Removed from v.1.39  
changed lines
  Added in v.1.40


______________
© Copyright 1998-2020, OpenLDAP Foundation, info@OpenLDAP.org