Diff for /servers/slapd/overlays/syncprov.c between versions 1.147.2.3 and 1.165

version 1.147.2.3, 2006/10/19 20:06:55 version 1.165, 2007/01/02 19:01:14
Line 1 Line 1
 /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.2 2006/08/17 23:50:32 kurt Exp $ */  /* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.164 2006/12/02 09:42:42 ando 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/>.
  *   *
  * Copyright 2004-2006 The OpenLDAP Foundation.   * Copyright 2004-2007 The OpenLDAP Foundation.
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 1260  syncprov_op_cleanup( Operation *op, Slap Line 1260  syncprov_op_cleanup( Operation *op, Slap
 }  }
   
 static void  static void
 syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )  syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on,
           struct berval *csn )
 {  {
         syncprov_info_t         *si = on->on_bi.bi_private;  
         Modifications mod;          Modifications mod;
         Operation opm;          Operation opm;
         SlapReply rsm = { 0 };          SlapReply rsm = { 0 };
Line 1270  syncprov_checkpoint( Operation *op, Slap Line 1270  syncprov_checkpoint( Operation *op, Slap
         slap_callback cb = {0};          slap_callback cb = {0};
   
         /* If ctxcsn is empty, delete it */          /* If ctxcsn is empty, delete it */
         if ( BER_BVISEMPTY( &si->si_ctxcsn )) {          if ( BER_BVISEMPTY( csn )) {
                 mod.sml_values = NULL;                  mod.sml_values = NULL;
         } else {          } else {
                 mod.sml_values = bv;                  mod.sml_values = bv;
                 bv[1].bv_val = NULL;                  bv[1].bv_val = NULL;
                 bv[0] = si->si_ctxcsn;                  bv[0] = *csn;
         }          }
         mod.sml_nvalues = NULL;          mod.sml_nvalues = NULL;
         mod.sml_desc = slap_schema.si_ad_contextCSN;          mod.sml_desc = slap_schema.si_ad_contextCSN;
Line 1510  syncprov_op_response( Operation *op, Sla Line 1510  syncprov_op_response( Operation *op, Sla
         {          {
                 struct berval maxcsn = BER_BVNULL;                  struct berval maxcsn = BER_BVNULL;
                 char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];                  char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
                   int do_check = 0;
   
                 /* Update our context CSN */                  /* Update our context CSN */
                 cbuf[0] = '\0';                  cbuf[0] = '\0';
Line 1532  syncprov_op_response( Operation *op, Sla Line 1533  syncprov_op_response( Operation *op, Sla
   
                 si->si_numops++;                  si->si_numops++;
                 if ( si->si_chkops || si->si_chktime ) {                  if ( si->si_chkops || si->si_chktime ) {
                         int do_check=0;  
                         if ( si->si_chkops && si->si_numops >= si->si_chkops ) {                          if ( si->si_chkops && si->si_numops >= si->si_chkops ) {
                                 do_check = 1;                                  do_check = 1;
                                 si->si_numops = 0;                                  si->si_numops = 0;
Line 1542  syncprov_op_response( Operation *op, Sla Line 1542  syncprov_op_response( Operation *op, Sla
                                 do_check = 1;                                  do_check = 1;
                                 si->si_chklast = op->o_time;                                  si->si_chklast = op->o_time;
                         }                          }
                         if ( do_check ) {  
                                 syncprov_checkpoint( op, rs, on );  
                         }  
                 }                  }
                 ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex );                  ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex );
   
                 opc->sctxcsn.bv_len = maxcsn.bv_len;                  opc->sctxcsn.bv_len = maxcsn.bv_len;
                 opc->sctxcsn.bv_val = cbuf;                  opc->sctxcsn.bv_val = cbuf;
   
                   if ( do_check ) {
                           syncprov_checkpoint( op, rs, on, &opc->sctxcsn );
                   }
   
                 /* Handle any persistent searches */                  /* Handle any persistent searches */
                 if ( si->si_ops ) {                  if ( si->si_ops ) {
                         switch(op->o_tag) {                          switch(op->o_tag) {
Line 2280  sp_cf_gen(ConfigArgs *c) Line 2281  sp_cf_gen(ConfigArgs *c)
         switch ( c->type ) {          switch ( c->type ) {
         case SP_CHKPT:          case SP_CHKPT:
                 if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) {                  if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) {
                         sprintf( c->msg, "%s unable to parse checkpoint ops # \"%s\"",                          snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint ops # \"%s\"",
                                 c->argv[0], c->argv[1] );                                  c->argv[0], c->argv[1] );
                         Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );                          Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
                                   "%s: %s\n", c->log, c->msg, 0 );
                         return ARG_BAD_CONF;                          return ARG_BAD_CONF;
                 }                  }
                 if ( si->si_chkops <= 0 ) {                  if ( si->si_chkops <= 0 ) {
                         sprintf( c->msg, "%s invalid checkpoint ops # \"%d\"",                          snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint ops # \"%d\"",
                                 c->argv[0], si->si_chkops );                                  c->argv[0], si->si_chkops );
                         Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );                          Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
                                   "%s: %s\n", c->log, c->msg, 0 );
                         return ARG_BAD_CONF;                          return ARG_BAD_CONF;
                 }                  }
                 if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) {                  if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) {
                         sprintf( c->msg, "%s unable to parse checkpoint time \"%s\"",                          snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint time \"%s\"",
                                 c->argv[0], c->argv[1] );                                  c->argv[0], c->argv[1] );
                         Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );                          Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
                                   "%s: %s\n", c->log, c->msg, 0 );
                         return ARG_BAD_CONF;                          return ARG_BAD_CONF;
                 }                  }
                 if ( si->si_chktime <= 0 ) {                  if ( si->si_chktime <= 0 ) {
                         sprintf( c->msg, "%s invalid checkpoint time \"%d\"",                          snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint time \"%d\"",
                                 c->argv[0], si->si_chkops );                                  c->argv[0], si->si_chkops );
                         Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );                          Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
                                   "%s: %s\n", c->log, c->msg, 0 );
                         return ARG_BAD_CONF;                          return ARG_BAD_CONF;
                 }                  }
                 si->si_chktime *= 60;                  si->si_chktime *= 60;
Line 2310  sp_cf_gen(ConfigArgs *c) Line 2315  sp_cf_gen(ConfigArgs *c)
                 int size = c->value_int;                  int size = c->value_int;
   
                 if ( size < 0 ) {                  if ( size < 0 ) {
                         sprintf( c->msg, "%s size %d is negative",                          snprintf( c->msg, sizeof( c->msg ), "%s size %d is negative",
                                 c->argv[0], size );                                  c->argv[0], size );
                         Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );                          Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
                                   "%s: %s\n", c->log, c->msg, 0 );
                         return ARG_BAD_CONF;                          return ARG_BAD_CONF;
                 }                  }
                 sl = si->si_logs;                  sl = si->si_logs;
Line 2472  syncprov_db_close( Line 2478  syncprov_db_close(
                 op->o_bd = be;                  op->o_bd = be;
                 op->o_dn = be->be_rootdn;                  op->o_dn = be->be_rootdn;
                 op->o_ndn = be->be_rootndn;                  op->o_ndn = be->be_rootndn;
                 syncprov_checkpoint( op, &rs, on );                  syncprov_checkpoint( op, &rs, on, &si->si_ctxcsn );
                 ldap_pvt_thread_pool_context_reset( thrctx );                  ldap_pvt_thread_pool_context_reset( thrctx );
         }          }
   
Line 2487  syncprov_db_init( Line 2493  syncprov_db_init(
         slap_overinst   *on = (slap_overinst *)be->bd_info;          slap_overinst   *on = (slap_overinst *)be->bd_info;
         syncprov_info_t *si;          syncprov_info_t *si;
   
           if ( SLAP_ISGLOBALOVERLAY( be ) ) {
                   Debug( LDAP_DEBUG_ANY,
                           "syncprov must be instantiated within a database.\n",
                           0, 0, 0 );
                   return 1;
           }
   
         si = ch_calloc(1, sizeof(syncprov_info_t));          si = ch_calloc(1, sizeof(syncprov_info_t));
         on->on_bi.bi_private = si;          on->on_bi.bi_private = si;
         ldap_pvt_thread_mutex_init( &si->si_csn_mutex );          ldap_pvt_thread_mutex_init( &si->si_csn_mutex );

Removed from v.1.147.2.3  
changed lines
  Added in v.1.165


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