Diff for /servers/slapd/overlays/syncprov.c between versions 1.44 and 1.45

version 1.44, 2004/12/07 17:52:55 version 1.45, 2004/12/07 23:47:25
Line 1 Line 1
 /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.43 2004/12/07 09:43:48 hyc Exp $ */  /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.44 2004/12/07 17:52:55 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 56  typedef struct syncops { Line 56  typedef struct syncops {
         struct berval   s_base;         /* ndn of search base */          struct berval   s_base;         /* ndn of search base */
         ID              s_eid;          /* entryID of search base */          ID              s_eid;          /* entryID of search base */
         Operation       *s_op;          /* search op */          Operation       *s_op;          /* search op */
         long    s_sid;          int             s_sid;
         long    s_rid;          int             s_rid;
         struct berval s_filterstr;          struct berval s_filterstr;
         int             s_flags;        /* search status */          int             s_flags;        /* search status */
         int             s_inuse;        /* reference count */          int             s_inuse;        /* reference count */
Line 91  typedef struct syncmatches { Line 91  typedef struct syncmatches {
         syncops *sm_op;          syncops *sm_op;
 } syncmatches;  } syncmatches;
   
   /* Session log data */
   typedef struct slog_entry {
           struct slog_entry *se_next;
           struct berval se_uuid;
           struct berval se_csn;
           ber_tag_t       se_tag;
   } slog_entry;
   
   typedef struct sessionlog {
           struct sessionlog *sl_next;
           int             sl_sid;
           struct berval   sl_mincsn;
           int             sl_num;
           int             sl_size;
           slog_entry *sl_head;
           slog_entry *sl_tail;
           ldap_pvt_thread_mutex_t sl_mutex;
   } sessionlog;
   
 /* The main state for this overlay */  /* The main state for this overlay */
 typedef struct syncprov_info_t {  typedef struct syncprov_info_t {
         syncops         *si_ops;          syncops         *si_ops;
Line 100  typedef struct syncprov_info_t { Line 119  typedef struct syncprov_info_t {
         int             si_numops;      /* number of ops since last checkpoint */          int             si_numops;      /* number of ops since last checkpoint */
         time_t  si_chklast;     /* time of last checkpoint */          time_t  si_chklast;     /* time of last checkpoint */
         Avlnode *si_mods;       /* entries being modified */          Avlnode *si_mods;       /* entries being modified */
           sessionlog      *si_logs;
         ldap_pvt_thread_mutex_t si_csn_mutex;          ldap_pvt_thread_mutex_t si_csn_mutex;
         ldap_pvt_thread_mutex_t si_ops_mutex;          ldap_pvt_thread_mutex_t si_ops_mutex;
         ldap_pvt_thread_mutex_t si_mods_mutex;          ldap_pvt_thread_mutex_t si_mods_mutex;
Line 539  findpres_cb( Operation *op, SlapReply *r Line 559  findpres_cb( Operation *op, SlapReply *r
 {  {
         slap_callback *sc = op->o_callback;          slap_callback *sc = op->o_callback;
         fpres_cookie *pc = sc->sc_private;          fpres_cookie *pc = sc->sc_private;
           Attribute *a;
         int ret = SLAP_CB_CONTINUE;          int ret = SLAP_CB_CONTINUE;
   
         if ( rs->sr_type == REP_SEARCH ) {          switch ( rs->sr_type ) {
                 Attribute *a = attr_find( rs->sr_entry->e_attrs,          case REP_SEARCH:
                         slap_schema.si_ad_entryUUID );                  a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID );
                 if ( a ) {                  if ( a ) {
                         pc->uuids[pc->num].bv_val = pc->last;                          pc->uuids[pc->num].bv_val = pc->last;
                         AC_MEMCPY( pc->uuids[pc->num].bv_val, a->a_nvals[0].bv_val,                          AC_MEMCPY( pc->uuids[pc->num].bv_val, a->a_nvals[0].bv_val,
Line 553  findpres_cb( Operation *op, SlapReply *r Line 574  findpres_cb( Operation *op, SlapReply *r
                         pc->uuids[pc->num].bv_val = NULL;                          pc->uuids[pc->num].bv_val = NULL;
                 }                  }
                 ret = LDAP_SUCCESS;                  ret = LDAP_SUCCESS;
                 if ( pc->num == SLAP_SYNCUUID_SET_SIZE ) {                  if ( pc->num != SLAP_SYNCUUID_SET_SIZE )
                         ret = syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL,                          break;
                                 0, pc->uuids, 0 );                  /* FALLTHRU */
                         pc->uuids[pc->num].bv_val = pc->last;          case REP_RESULT:
                         pc->num = 0;  
                         pc->last = pc->uuids[0].bv_val;  
                 }  
   
         } 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,
Line 570  findpres_cb( Operation *op, SlapReply *r Line 586  findpres_cb( Operation *op, SlapReply *r
                         pc->num = 0;                          pc->num = 0;
                         pc->last = pc->uuids[0].bv_val;                          pc->last = pc->uuids[0].bv_val;
                 }                  }
                   break;
           default:
                   break;
         }          }
         return ret;          return ret;
 }  }
Line 1056  syncprov_checkpoint( Operation *op, Slap Line 1075  syncprov_checkpoint( Operation *op, Slap
         opm.o_bd->be_modify( &opm, rs );          opm.o_bd->be_modify( &opm, rs );
 }  }
   
   static void
   syncprov_add_slog( Operation *op, struct berval *csn )
   {
           opcookie *opc = op->o_callback->sc_private;
           slap_overinst *on = opc->son;
           syncprov_info_t         *si = on->on_bi.bi_private;
           sessionlog *sl;
           slog_entry *se;
   
           for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
                   /* Allocate a record. UUIDs are not NUL-terminated. */
                   se = ch_malloc( sizeof( slog_entry ) + opc->suuid.bv_len + 
                           csn->bv_len + 1 );
                   se->se_next = NULL;
                   se->se_tag = op->o_tag;
   
                   se->se_uuid.bv_val = (char *)(se+1);
                   se->se_csn.bv_val = se->se_uuid.bv_val + opc->suuid.bv_len + 1;
                   AC_MEMCPY( se->se_uuid.bv_val, opc->suuid.bv_val, opc->suuid.bv_len );
                   se->se_uuid.bv_len = opc->suuid.bv_len;
   
                   AC_MEMCPY( se->se_csn.bv_val, csn->bv_val, csn->bv_len );
                   se->se_csn.bv_val[csn->bv_len] = '\0';
                   se->se_csn.bv_len = csn->bv_len;
   
                   ldap_pvt_thread_mutex_lock( &sl->sl_mutex );
                   if ( sl->sl_head ) {
                           sl->sl_tail->se_next = se;
                   } else {
                           sl->sl_head = se;
                   }
                   sl->sl_tail = se;
                   sl->sl_num++;
                   while ( sl->sl_num > sl->sl_size ) {
                           se = sl->sl_head;
                           sl->sl_head = se->se_next;
                           strcpy( sl->sl_mincsn.bv_val, se->se_csn.bv_val );
                           sl->sl_mincsn.bv_len = se->se_csn.bv_len;
                           ch_free( se );
                           sl->sl_num--;
                           if ( !sl->sl_head ) {
                                   sl->sl_tail = NULL;
                           }
                   }
                   ldap_pvt_thread_mutex_unlock( &sl->sl_mutex );
           }
   }
   
   /* Just set a flag if we found the matching entry */
   static int
   playlog_cb( Operation *op, SlapReply *rs )
   {
           if ( rs->sr_type == REP_SEARCH ) {
                   op->o_callback->sc_private = (void *)1;
           }
           return rs->sr_err;
   }
   
   /* enter with sl->sl_mutex locked, release before returning */
   static void
   syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl,
           struct berval *oldcsn, struct berval *ctxcsn )
   {
           slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
           syncprov_info_t         *si = on->on_bi.bi_private;
           slog_entry *se;
           int i, j, ndel, num, nmods, mmods;
           BerVarray uuids;
   
           num = sl->sl_num;
           i = 0;
           nmods = 0;
   
           uuids = op->o_tmpalloc( (num+1) * sizeof( struct berval ) +
                   num * UUID_LEN, op->o_tmpmemctx );
   
           uuids[0].bv_val = (char *)(uuids + num + 1);
   
           /* Make a copy of the relevant UUIDs. Put the Deletes up front
            * and everything else at the end. Do this first so we can
            * unlock the list mutex.
            */
           for ( se=sl->sl_head; se; se=se->se_next ) {
                   if ( ber_bvcmp( &se->se_csn, oldcsn ) < 0 ) continue;
                   if ( ber_bvcmp( &se->se_csn, ctxcsn ) > 0 ) break;
                   if ( se->se_tag == LDAP_REQ_DELETE ) {
                           j = i;
                           i++;
                   } else {
                           nmods++;
                           j = num - nmods;
                   }
                   uuids[j].bv_val = uuids[0].bv_val + (j * UUID_LEN);
                   AC_MEMCPY(uuids[j].bv_val, se->se_uuid.bv_val, UUID_LEN);
                   uuids[j].bv_len = UUID_LEN;
           }
           ldap_pvt_thread_mutex_unlock( &sl->sl_mutex );
   
           ndel = i;
   
           /* Mods must be validated to see if they belong in this delete set.
            */
   
           mmods = nmods;
           /* Strip any duplicates */
           for ( i=0; i<nmods; i++ ) {
                   for ( j=0; j<ndel; j++ ) {
                           if ( bvmatch( &uuids[j], &uuids[num - 1 - i] )) {
                                   uuids[num - 1 - i].bv_len = 0;
                                   mmods --;
                                   break;
                           }
                   }
                   if ( uuids[num - 1 - i].bv_len == 0 ) continue;
                   for ( j=0; j<i; j++ ) {
                           if ( bvmatch( &uuids[num - 1 - j], &uuids[num - 1 - i] )) {
                                   uuids[num - 1 - i].bv_len = 0;
                                   mmods --;
                                   break;
                           }
                   }
           }
   
           if ( mmods ) {
                   Operation fop;
                   SlapReply frs = { REP_RESULT };
                   int rc;
                   Filter mf, af;
                   AttributeAssertion eq;
                   slap_callback cb = {0};
   
                   fop = *op;
   
                   fop.o_sync_mode = 0;
                   fop.o_callback = &cb;
                   fop.ors_limit = NULL;
                   fop.ors_slimit = 1;
                   fop.ors_tlimit = SLAP_NO_LIMIT;
                   fop.ors_attrs = slap_anlist_all_attributes;
                   fop.ors_attrsonly = 0;
                   fop.o_managedsait = SLAP_CONTROL_CRITICAL;
   
                   af.f_choice = LDAP_FILTER_AND;
                   af.f_next = NULL;
                   af.f_and = &mf;
                   mf.f_choice = LDAP_FILTER_EQUALITY;
                   mf.f_ava = &eq;
                   mf.f_av_desc = slap_schema.si_ad_entryUUID;
                   mf.f_next = fop.ors_filter;
   
                   fop.ors_filter = &af;
   
                   cb.sc_response = playlog_cb;
   
                   for ( i=0; i<nmods; i++ ) {
                           if ( uuids[num - 1 - 1].bv_len == 0 ) continue;
   
                           mf.f_av_value = uuids[num -1 -i];
                           filter2bv_x( &fop, fop.ors_filter, &fop.ors_filterstr );
                           fop.o_bd->bd_info = on->on_info->oi_orig;
                           cb.sc_private = NULL;
                           rc = fop.o_bd->be_search( &fop, &frs );
                           fop.o_bd->bd_info = (BackendInfo *)on;
                           op->o_tmpfree( fop.ors_filterstr.bv_val, op->o_tmpmemctx );
   
                           /* If entry was not found, add to delete list */
                           if ( !cb.sc_private ) {
                                   uuids[ndel++] = uuids[num - 1 - i];
                           }
                   }
           }
           if ( ndel ) {
                   uuids[ndel].bv_val = NULL;
                   syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL, 0, uuids, 1 );
           }
   }
   
 static int  static int
 syncprov_op_response( Operation *op, SlapReply *rs )  syncprov_op_response( Operation *op, SlapReply *rs )
 {  {
Line 1066  syncprov_op_response( Operation *op, Sla Line 1262  syncprov_op_response( Operation *op, Sla
   
         if ( rs->sr_err == LDAP_SUCCESS )          if ( rs->sr_err == LDAP_SUCCESS )
         {          {
                 struct berval maxcsn;                  struct berval maxcsn = BER_BVNULL, curcsn = BER_BVNULL;
                 char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];                  char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
   
                 /* Update our context CSN */                  /* Update our context CSN */
                 cbuf[0] = '\0';                  cbuf[0] = '\0';
                 ldap_pvt_thread_mutex_lock( &si->si_csn_mutex );                  ldap_pvt_thread_mutex_lock( &si->si_csn_mutex );
                 slap_get_commit_csn( op, &maxcsn );                  slap_get_commit_csn( op, &maxcsn, &curcsn );
                 if ( !BER_BVISNULL( &maxcsn ) ) {                  if ( !BER_BVISNULL( &maxcsn ) ) {
                         strcpy( cbuf, maxcsn.bv_val );                          strcpy( cbuf, maxcsn.bv_val );
                         if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn ) > 0 ) {                          if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn ) > 0 ) {
Line 1127  syncprov_op_response( Operation *op, Sla Line 1323  syncprov_op_response( Operation *op, Sla
                         }                          }
                 }                  }
   
                   /* Add any log records */
                   if ( si->si_logs && op->o_tag != LDAP_REQ_ADD ) {
                           syncprov_add_slog( op, &curcsn );
                   }
   
         }          }
         return SLAP_CB_CONTINUE;          return SLAP_CB_CONTINUE;
 }  }
Line 1255  syncprov_op_mod( Operation *op, SlapRepl Line 1456  syncprov_op_mod( Operation *op, SlapRepl
                         avl_insert( &si->si_mods, mt, sp_avl_cmp, avl_dup_error );                          avl_insert( &si->si_mods, mt, sp_avl_cmp, avl_dup_error );
                         ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );                          ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
                 }                  }
   
                 if ( op->o_tag != LDAP_REQ_ADD )  
                         syncprov_matchops( op, opc, 1 );  
         }          }
   
           if (( si->si_ops || si->si_logs ) && op->o_tag != LDAP_REQ_ADD )
                   syncprov_matchops( op, opc, 1 );
                   
   
         return SLAP_CB_CONTINUE;          return SLAP_CB_CONTINUE;
 }  }
   
Line 1275  syncprov_op_extended( Operation *op, Sla Line 1477  syncprov_op_extended( Operation *op, Sla
 typedef struct searchstate {  typedef struct searchstate {
         slap_overinst *ss_on;          slap_overinst *ss_on;
         syncops *ss_so;          syncops *ss_so;
           int ss_present;
 } searchstate;  } searchstate;
   
 static int  static int
Line 1390  syncprov_search_response( Operation *op, Line 1593  syncprov_search_response( Operation *op,
                                 op->o_tmpmemctx );                                  op->o_tmpmemctx );
                         rs->sr_ctrls[1] = NULL;                          rs->sr_ctrls[1] = NULL;
                         rs->sr_err = syncprov_done_ctrl( op, rs, rs->sr_ctrls,                          rs->sr_err = syncprov_done_ctrl( op, rs, rs->sr_ctrls,
                                 0, 1, &cookie, LDAP_SYNC_REFRESH_PRESENTS );                                  0, 1, &cookie, ss->ss_present ?  LDAP_SYNC_REFRESH_PRESENTS :
                                           LDAP_SYNC_REFRESH_DELETES );
                 } else {                  } else {
                         int locked = 0;                          int locked = 0;
                 /* It's RefreshAndPersist, transition to Persist phase */                  /* It's RefreshAndPersist, transition to Persist phase */
                         syncprov_sendinfo( op, rs, rs->sr_nentries ?                          syncprov_sendinfo( op, rs, ss->ss_present ?
                                 LDAP_TAG_SYNC_REFRESH_PRESENT : LDAP_TAG_SYNC_REFRESH_DELETE,                                  LDAP_TAG_SYNC_REFRESH_PRESENT : LDAP_TAG_SYNC_REFRESH_DELETE,
                                 &cookie, 1, NULL, 0 );                                  &cookie, 1, NULL, 0 );
                         /* Flush any queued persist messages */                          /* Flush any queued persist messages */
Line 1457  syncprov_op_search( Operation *op, SlapR Line 1661  syncprov_op_search( Operation *op, SlapR
         slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;          slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
         syncprov_info_t         *si = (syncprov_info_t *)on->on_bi.bi_private;          syncprov_info_t         *si = (syncprov_info_t *)on->on_bi.bi_private;
         slap_callback   *cb;          slap_callback   *cb;
         int gotstate = 0, nochange = 0;          int gotstate = 0, nochange = 0, do_present = 1;
         Filter *fand, *fava;          Filter *fand, *fava;
         syncops *sop = NULL;          syncops *sop = NULL;
         searchstate *ss;          searchstate *ss;
         sync_control *srs;          sync_control *srs;
           struct berval ctxcsn;
           char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
   
         if ( !(op->o_sync_mode & SLAP_SYNC_REFRESH) ) return SLAP_CB_CONTINUE;          if ( !(op->o_sync_mode & SLAP_SYNC_REFRESH) ) return SLAP_CB_CONTINUE;
   
Line 1508  syncprov_op_search( Operation *op, SlapR Line 1714  syncprov_op_search( Operation *op, SlapR
                 ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );                  ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
         }          }
   
         /* If we have a cookie, handle the PRESENT lookups          /* snapshot the ctxcsn */
          */          ldap_pvt_thread_mutex_lock( &si->si_csn_mutex );
           strcpy( csnbuf, si->si_ctxcsnbuf );
           ctxcsn.bv_len = si->si_ctxcsn.bv_len;
           ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex );
           ctxcsn.bv_val = csnbuf;
           
           /* If we have a cookie, handle the PRESENT lookups */
         if ( srs->sr_state.ctxcsn ) {          if ( srs->sr_state.ctxcsn ) {
                   sessionlog *sl;
   
                 /* Is the CSN in a valid format? */                  /* Is the CSN in a valid format? */
                 if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) {                  if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) {
                         send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" );                          send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" );
                         return rs->sr_err;                          return rs->sr_err;
                 }                  }
                 /* If just Refreshing and nothing has changed, shortcut it */                  /* If just Refreshing and nothing has changed, shortcut it */
                 if ( bvmatch( srs->sr_state.ctxcsn, &si->si_ctxcsn )) {                  if ( bvmatch( srs->sr_state.ctxcsn, &ctxcsn )) {
                         nochange = 1;                          nochange = 1;
                         if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {                          if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
                                 LDAPControl     *ctrls[2];                                  LDAPControl     *ctrls[2];
Line 1534  syncprov_op_search( Operation *op, SlapR Line 1748  syncprov_op_search( Operation *op, SlapR
                         }                          }
                         goto shortcut;                          goto shortcut;
                 }                  }
                   /* Do we have a sessionlog for this search? */
                   for ( sl=si->si_logs; sl; sl=sl->sl_next )
                           if ( sl->sl_sid == srs->sr_state.sid ) break;
                   if ( sl ) {
                           ldap_pvt_thread_mutex_lock( &sl->sl_mutex );
                           if ( ber_bvcmp( srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) {
                                   do_present = 0;
                                   /* mutex is unlocked in playlog */
                                   syncprov_playlog( op, rs, sl, srs->sr_state.ctxcsn, &ctxcsn );
                           } else {
                                   ldap_pvt_thread_mutex_unlock( &sl->sl_mutex );
                           }
                   }
                 /* Is the CSN still present in the database? */                  /* Is the CSN still present in the database? */
                 if ( syncprov_findcsn( op, FIND_CSN ) != LDAP_SUCCESS ) {                  if ( syncprov_findcsn( op, FIND_CSN ) != LDAP_SUCCESS ) {
                         /* No, so a reload is required */                          /* No, so a reload is required */
Line 1545  syncprov_op_search( Operation *op, SlapR Line 1772  syncprov_op_search( Operation *op, SlapR
 #endif  #endif
                 } else {                  } else {
                         gotstate = 1;                          gotstate = 1;
                         /* If context has changed, check for Present UUIDs */                          /* If changed and doing Present lookup, send Present UUIDs */
                         if ( syncprov_findcsn( op, FIND_PRESENT ) != LDAP_SUCCESS ) {                          if ( do_present && syncprov_findcsn( op, FIND_PRESENT ) !=
                                   LDAP_SUCCESS ) {
                                 send_ldap_result( op, rs );                                  send_ldap_result( op, rs );
                                 return rs->sr_err;                                  return rs->sr_err;
                         }                          }
Line 1567  syncprov_op_search( Operation *op, SlapR Line 1795  syncprov_op_search( Operation *op, SlapR
         fava->f_choice = LDAP_FILTER_LE;          fava->f_choice = LDAP_FILTER_LE;
         fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx );          fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx );
         fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN;          fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN;
         ldap_pvt_thread_mutex_lock( &si->si_csn_mutex );          ber_dupbv_x( &fava->f_ava->aa_value, &ctxcsn, op->o_tmpmemctx );
         ber_dupbv_x( &fava->f_ava->aa_value, &si->si_ctxcsn, op->o_tmpmemctx );  
         ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex );  
         fand->f_and = fava;          fand->f_and = fava;
         if ( gotstate ) {          if ( gotstate ) {
                 fava->f_next = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx );                  fava->f_next = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx );
Line 1589  shortcut: Line 1815  shortcut:
         ss = (searchstate *)(cb+1);          ss = (searchstate *)(cb+1);
         ss->ss_on = on;          ss->ss_on = on;
         ss->ss_so = sop;          ss->ss_so = sop;
           ss->ss_present = do_present;
         cb->sc_response = syncprov_search_response;          cb->sc_response = syncprov_search_response;
         cb->sc_cleanup = syncprov_search_cleanup;          cb->sc_cleanup = syncprov_search_cleanup;
         cb->sc_private = ss;          cb->sc_private = ss;
Line 1679  syncprov_db_config( Line 1906  syncprov_db_config(
                 si->si_chktime = atoi( argv[2] ) * 60;                  si->si_chktime = atoi( argv[2] ) * 60;
                 return 0;                  return 0;
   
           } else if ( strcasecmp( argv[0], "syncprov-sessionlog" ) == 0 ) {
                   sessionlog *sl;
                   int sid, size;
                   if ( argc != 3 ) {
                           fprintf( stderr, "%s: line %d: wrong number of arguments in "
                                   "\"syncprov-sessionlog <sid> <size>\"\n", fname, lineno );
                           return -1;
                   }
                   sid = atoi( argv[1] );
                   if ( sid < 0 || sid > 999 ) {
                           fprintf( stderr,
                                   "%s: line %d: session log id %d is out of range [0..999]\n",
                                   fname, lineno, sid );
                           return -1;
                   }
                   size = atoi( argv[2] );
                   if ( size < 0 ) {
                           fprintf( stderr,
                                   "%s: line %d: session log size %d is negative\n",
                                   fname, lineno, size );
                           return -1;
                   }
                   for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
                           if ( sl->sl_sid == sid ) {
                                   sl->sl_size = size;
                                   break;
                           }
                   }
                   if ( !sl ) {
                           sl = ch_malloc( sizeof( sessionlog ) + LDAP_LUTIL_CSNSTR_BUFSIZE );
                           sl->sl_mincsn.bv_val = (char *)(sl+1);
                           sl->sl_mincsn.bv_len = 0;
                           sl->sl_sid = sid;
                           sl->sl_size = size;
                           sl->sl_num = 0;
                           sl->sl_head = sl->sl_tail = NULL;
                           sl->sl_next = si->si_logs;
                           ldap_pvt_thread_mutex_init( &sl->sl_mutex );
                           si->si_logs = sl;
                   }
                   return 0;
         }          }
   
         return SLAP_CONF_UNKNOWN;          return SLAP_CONF_UNKNOWN;

Removed from v.1.44  
changed lines
  Added in v.1.45


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