allow per-replogfile pid/args file & replication interval (ITS#3523)

This commit is contained in:
Pierangelo Masarati 2005-12-10 12:25:27 +00:00
parent b681c634c4
commit 8687dace5b
3 changed files with 128 additions and 15 deletions

View File

@ -69,12 +69,6 @@ typedef struct {
int cb_use_ldif; int cb_use_ldif;
} CfBackInfo; } CfBackInfo;
/* These do nothing in slapd, they're kept only to make them
* editable here.
*/
static char *replica_pidFile, *replica_argsFile;
static int replicationInterval;
static char *passwd_salt; static char *passwd_salt;
static char *logfileName; static char *logfileName;
#ifdef SLAP_AUTH_REWRITE #ifdef SLAP_AUTH_REWRITE
@ -149,6 +143,9 @@ enum {
CFG_DIT, CFG_DIT,
CFG_ATTR, CFG_ATTR,
CFG_ATOPT, CFG_ATOPT,
CFG_REPLICA_ARGSFILE,
CFG_REPLICA_PIDFILE,
CFG_REPLICATIONINTERVAL,
CFG_REPLOG, CFG_REPLOG,
CFG_ROOTDSE, CFG_ROOTDSE,
CFG_LOGFILE, CFG_LOGFILE,
@ -411,14 +408,14 @@ static ConfigTable config_back_cf_table[] = {
{ "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC, { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
&config_replica, "( OLcfgDbAt:0.7 NAME 'olcReplica' " &config_replica, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
"SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL }, "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
{ "replica-argsfile", NULL, 0, 0, 0, ARG_STRING, { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLICA_ARGSFILE,
&replica_argsFile, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' " &config_generic, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "replica-pidfile", NULL, 0, 0, 0, ARG_STRING, { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLICA_PIDFILE,
&replica_pidFile, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' " &config_generic, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "replicationInterval", NULL, 0, 0, 0, ARG_INT, { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|ARG_INT|CFG_REPLICATIONINTERVAL,
&replicationInterval, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' " &config_generic, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
{ "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG, { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
&config_generic, "( OLcfgGlAt:46 NAME 'olcReplogFile' " &config_generic, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
@ -637,7 +634,6 @@ static ConfigOCs cf_ocs[] = {
"olcLogLevel $ " "olcLogLevel $ "
"olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ " "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
"olcPluginLogFile $ olcReadOnly $ olcReferral $ " "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
"olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
"olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ " "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
"olcRootDSE $ " "olcRootDSE $ "
"olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ " "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
@ -669,6 +665,7 @@ static ConfigOCs cf_ocs[] = {
"MUST olcDatabase " "MUST olcDatabase "
"MAY ( olcSuffix $ olcSubordinate $ olcAccess $ olcLastMod $ olcLimits $ " "MAY ( olcSuffix $ olcSubordinate $ olcAccess $ olcLastMod $ olcLimits $ "
"olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ " "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
"olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
"olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ " "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
"olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ " "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
"olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )", "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
@ -854,6 +851,21 @@ config_generic(ConfigArgs *c) {
rc = (!i); rc = (!i);
break; break;
} }
case CFG_REPLICA_ARGSFILE:
if ( c->be->be_replica_argsfile )
c->value_string = ch_strdup( c->be->be_replica_argsfile );
break;
case CFG_REPLICA_PIDFILE:
if ( c->be->be_replica_pidfile )
c->value_string = ch_strdup( c->be->be_replica_pidfile );
break;
case CFG_REPLICATIONINTERVAL:
if ( c->be->be_replicationinterval > 0 ) {
c->value_int = c->be->be_replicationinterval;
} else {
rc = 1;
}
break;
case CFG_REPLOG: case CFG_REPLOG:
if ( c->be->be_replogfile ) if ( c->be->be_replogfile )
c->value_string = ch_strdup( c->be->be_replogfile ); c->value_string = ch_strdup( c->be->be_replogfile );
@ -980,6 +992,20 @@ config_generic(ConfigArgs *c) {
passwd_salt = NULL; passwd_salt = NULL;
break; break;
case CFG_REPLICA_ARGSFILE:
ch_free( c->be->be_replica_argsfile );
c->be->be_replica_argsfile = NULL;
break;
case CFG_REPLICA_PIDFILE:
ch_free( c->be->be_replica_pidfile );
c->be->be_replica_pidfile = NULL;
break;
case CFG_REPLICATIONINTERVAL:
c->be->be_replicationinterval = 0;
break;
case CFG_REPLOG: case CFG_REPLOG:
ch_free( c->be->be_replogfile ); ch_free( c->be->be_replogfile );
c->be->be_replogfile = NULL; c->be->be_replogfile = NULL;
@ -1188,13 +1214,80 @@ config_generic(ConfigArgs *c) {
} }
break; break;
case CFG_REPLICA_ARGSFILE:
if(SLAP_MONITOR(c->be)) {
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replica-argsfile\" should not be used "
"inside monitor database\n",
c->log, 0, 0);
/* FIXME: should this be an error? */
return(0);
}
if ( c->be->be_replica_argsfile != NULL ) {
/* FIXME: error? */
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replica-argsfile\" already provided; "
"replacing \"%s\" with \"%s\".\n",
c->log, c->be->be_replica_argsfile, c->value_string );
ch_free( c->be->be_replica_argsfile );
}
c->be->be_replica_argsfile = c->value_string;
break;
case CFG_REPLICA_PIDFILE:
if(SLAP_MONITOR(c->be)) {
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replica-pidfile\" should not be used "
"inside monitor database\n",
c->log, 0, 0);
/* FIXME: should this be an error? */
return(0);
}
if ( c->be->be_replica_pidfile != NULL ) {
/* FIXME: error? */
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replica-pidfile\" already provided; "
"replacing \"%s\" with \"%s\".\n",
c->log, c->be->be_replica_pidfile, c->value_string );
ch_free( c->be->be_replica_pidfile );
}
c->be->be_replica_pidfile = c->value_string;
break;
case CFG_REPLICATIONINTERVAL:
if(SLAP_MONITOR(c->be)) {
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replicationinterval\" should not be used "
"inside monitor database\n",
c->log, 0, 0);
/* FIXME: should this be an error? */
return(0);
}
c->be->be_replicationinterval = c->value_int;
break;
case CFG_REPLOG: case CFG_REPLOG:
if(SLAP_MONITOR(c->be)) { if(SLAP_MONITOR(c->be)) {
Debug(LDAP_DEBUG_ANY, "%s: " Debug(LDAP_DEBUG_ANY, "%s: "
"\"replogfile\" should not be used " "\"replogfile\" should not be used "
"inside monitor database\n", "inside monitor database\n",
c->log, 0, 0); c->log, 0, 0);
return(0); /* FIXME: should this be an error? */ /* FIXME: should this be an error? */
return(0);
}
if ( c->be->be_replogfile != NULL ) {
/* FIXME: error? */
Debug(LDAP_DEBUG_ANY, "%s: "
"\"replogfile\" already provided; "
"replacing \"%s\" with \"%s\".\n",
c->log, c->be->be_replogfile, c->value_string );
ch_free( c->be->be_replogfile );
} }
c->be->be_replogfile = c->value_string; c->be->be_replogfile = c->value_string;

View File

@ -1826,6 +1826,9 @@ struct slap_backend_db {
/* Replica Information */ /* Replica Information */
struct slap_replica_info **be_replica; /* replicas of this backend (in master) */ struct slap_replica_info **be_replica; /* replicas of this backend (in master) */
char *be_replogfile; /* replication log file (in master) */ char *be_replogfile; /* replication log file (in master) */
char *be_replica_argsfile; /* per-replog replica args file */
char *be_replica_pidfile; /* per-replog replica pid file */
int be_replicationinterval; /* per-replog replicationinterval */
struct berval be_update_ndn; /* allowed to make changes (in replicas) */ struct berval be_update_ndn; /* allowed to make changes (in replicas) */
BerVarray be_update_refs; /* where to refer modifying clients to */ BerVarray be_update_refs; /* where to refer modifying clients to */
struct be_pcl *be_pending_csn_list; struct be_pcl *be_pending_csn_list;

View File

@ -89,8 +89,10 @@ slurpd_read_config(
#define GOT_REPLOG_MASK (0xF) #define GOT_REPLOG_MASK (0xF)
#define GOT_REPLOG(i) ((i) & GOT_REPLOG_MASK) #define GOT_REPLOG(i) ((i) & GOT_REPLOG_MASK)
#define GOT_REPLOG_SET(i,v) ((i) = ((i) & ~GOT_REPLOG_MASK) | ((v) & GOT_REPLOG_MASK)) #define GOT_REPLOG_SET(i,v) ((i) = ((i) & ~GOT_REPLOG_MASK) | ((v) & GOT_REPLOG_MASK))
#define GOT_REPLOG_PID (0x10) #define GOT_REPLOG_PID (0x10)
#define GOT_REPLOG_ARGS (0x20) #define GOT_REPLOG_ARGS (0x20)
#define GOT_REPLOG_INTERVAL (0x40)
int got_replog = GOT_REPLOG_NO; int got_replog = GOT_REPLOG_NO;
/* /*
@ -271,7 +273,22 @@ slurpd_read_config(
return( 1 ); return( 1 );
} }
sglob->no_work_interval = c; switch ( GOT_REPLOG(got_replog) ) {
case GOT_REPLOG_YES:
Debug( LDAP_DEBUG_CONFIG, "%s: line %d: "
"got replog specific replicationinterval \"%s\".\n",
fname, lineno, cargv[1] );
case GOT_REPLOG_NO:
sglob->no_work_interval = c;
got_replog |= GOT_REPLOG_INTERVAL;
break;
default:
Debug( LDAP_DEBUG_CONFIG, "%s: line %d: "
"replicationinterval \"%s\" not mine.\n",
fname, lineno, cargv[1] );
break;
}
} }
} }