Diff for /servers/slapd/overlays/syncprov.c between versions 1.41 and 1.42

version 1.41, 2004/12/07 01:58:33 version 1.42, 2004/12/07 09:05:24
Line 1 Line 1
 /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.40 2004/12/07 01:20:15 hyc Exp $ */  /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.41 2004/12/07 01:58:33 hyc Exp $ */
 /* syncprov.c - syncrepl provider */  /* syncprov.c - syncrepl provider */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.  /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *   *
Line 526  findcsn_cb( Operation *op, SlapReply *rs Line 526  findcsn_cb( Operation *op, SlapReply *rs
   
 /* Build a list of entryUUIDs for sending in a SyncID set */  /* Build a list of entryUUIDs for sending in a SyncID set */
   
   #define UUID_LEN        16
   
 typedef struct fpres_cookie {  typedef struct fpres_cookie {
         int num;          int num;
         BerVarray uuids;          BerVarray uuids;
           char *last;
 } fpres_cookie;  } fpres_cookie;
   
 static int  static int
Line 539  findpres_cb( Operation *op, SlapReply *r Line 542  findpres_cb( Operation *op, SlapReply *r
         int ret = SLAP_CB_CONTINUE;          int ret = SLAP_CB_CONTINUE;
   
         if ( rs->sr_type == REP_SEARCH ) {          if ( rs->sr_type == REP_SEARCH ) {
                 ret = slap_build_syncUUID_set( op, &pc->uuids, rs->sr_entry );                  Attribute *a = attr_find( rs->sr_entry->e_attrs,
                 if ( ret > 0 ) {                          slap_schema.si_ad_entryUUID );
                   if ( a ) {
                           pc->uuids[pc->num].bv_val = pc->last;
                           AC_MEMCPY( pc->uuids[pc->num].bv_val, a->a_nvals[0].bv_val,
                                   pc->uuids[pc->num].bv_len );
                         pc->num++;                          pc->num++;
                         ret = LDAP_SUCCESS;                          pc->last = pc->uuids[pc->num].bv_val;
                         if ( pc->num == SLAP_SYNCUUID_SET_SIZE ) {                          pc->uuids[pc->num].bv_val = NULL;
                                 ret = syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL,  
                                         0, pc->uuids, 0 );  
                                 ber_bvarray_free_x( pc->uuids, op->o_tmpmemctx );  
                                 pc->uuids = NULL;  
                                 pc->num = 0;  
                         }  
                 } else {  
                         ret = LDAP_OTHER;  
                 }                  }
                   ret = LDAP_SUCCESS;
                   if ( pc->num == SLAP_SYNCUUID_SET_SIZE ) {
                           ret = syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL,
                                   0, pc->uuids, 0 );
                           pc->uuids[pc->num].bv_val = pc->last;
                           pc->num = 0;
                           pc->last = pc->uuids[0].bv_val;
                   }
   
         } else if ( rs->sr_type == REP_RESULT ) {          } else if ( rs->sr_type == REP_RESULT ) {
                 ret = rs->sr_err;                  ret = rs->sr_err;
                 if ( pc->num ) {                  if ( pc->num ) {
                         ret = syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL,                          ret = syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL,
                                 0, pc->uuids, 0 );                                  0, pc->uuids, 0 );
                         ber_bvarray_free_x( pc->uuids, op->o_tmpmemctx );                          pc->uuids[pc->num].bv_val = pc->last;
                         pc->uuids = NULL;  
                         pc->num = 0;                          pc->num = 0;
                           pc->last = pc->uuids[0].bv_val;
                 }                  }
         }          }
         return ret;          return ret;
 }  }
   
   
 static int  static int
 syncprov_findcsn( Operation *op, int mode )  syncprov_findcsn( Operation *op, int mode )
 {  {
Line 581  syncprov_findcsn( Operation *op, int mod Line 588  syncprov_findcsn( Operation *op, int mod
         struct berval fbuf, maxcsn;          struct berval fbuf, maxcsn;
         Filter cf;          Filter cf;
         AttributeAssertion eq;          AttributeAssertion eq;
         int rc = LDAP_SUCCESS;          int i, rc = LDAP_SUCCESS;
         fpres_cookie pcookie;          fpres_cookie pcookie;
         int locked = 0;  
         sync_control *srs;          sync_control *srs;
   
         if ( mode != FIND_MAXCSN ) {          if ( mode != FIND_MAXCSN ) {
Line 640  syncprov_findcsn( Operation *op, int mod Line 646  syncprov_findcsn( Operation *op, int mod
                 cb.sc_private = &pcookie;                  cb.sc_private = &pcookie;
                 cb.sc_response = findpres_cb;                  cb.sc_response = findpres_cb;
                 pcookie.num = 0;                  pcookie.num = 0;
                 pcookie.uuids = NULL;  
                   /* preallocate storage for a full set */
                   pcookie.uuids = op->o_tmpalloc( (SLAP_SYNCUUID_SET_SIZE+1) *
                           sizeof(struct berval) + SLAP_SYNCUUID_SET_SIZE * UUID_LEN,
                           op->o_tmpmemctx );
                   pcookie.last = (char *)(pcookie.uuids + SLAP_SYNCUUID_SET_SIZE+1);
                   pcookie.uuids[0].bv_val = pcookie.last;
                   pcookie.uuids[0].bv_len = UUID_LEN;
                   for (i=1; i<SLAP_SYNCUUID_SET_SIZE; i++) {
                           pcookie.uuids[i].bv_val = pcookie.uuids[i-1].bv_val + UUID_LEN;
                           pcookie.uuids[i].bv_len = UUID_LEN;
                   }
                 break;                  break;
         }          }
         fop.o_callback = &cb;          fop.o_callback = &cb;
Line 665  syncprov_findcsn( Operation *op, int mod Line 682  syncprov_findcsn( Operation *op, int mod
                 if ( !cb.sc_private ) rc = LDAP_NO_SUCH_OBJECT;                  if ( !cb.sc_private ) rc = LDAP_NO_SUCH_OBJECT;
                 break;                  break;
         case FIND_PRESENT:          case FIND_PRESENT:
                   op->o_tmpfree( pcookie.uuids, op->o_tmpmemctx );
                 break;                  break;
         }          }
   

Removed from v.1.41  
changed lines
  Added in v.1.42


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