version 1.56.2.6, 2005/04/29 21:29:10
|
version 1.56.2.7, 2005/05/10 16:07:04
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.56.2.5 2005/03/14 22:25:02 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.56.2.6 2005/04/29 21:29:10 kurt 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 25
|
Line 25
|
#include <ac/string.h> |
#include <ac/string.h> |
#include "lutil.h" |
#include "lutil.h" |
#include "slap.h" |
#include "slap.h" |
|
#include "config.h" |
|
|
/* A modify request on a particular entry */ |
/* A modify request on a particular entry */ |
typedef struct modinst { |
typedef struct modinst { |
Line 1994 syncprov_operational(
|
Line 1995 syncprov_operational(
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
|
enum { |
|
SP_CHKPT = 1, |
|
SP_SESSL |
|
}; |
|
|
|
static ConfigDriver sp_cf_gen; |
|
|
|
static ConfigTable spcfg[] = { |
|
{ "syncprov-checkpoint", "ops> <minutes", 3, 3, 0, ARG_MAGIC|SP_CHKPT, |
|
sp_cf_gen, "( OLcfgOvAt:1.1 NAME 'olcSpCheckpoint' " |
|
"DESC 'ContextCSN checkpoint interval in ops and minutes' " |
|
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, |
|
{ "syncprov-sessionlog", "size", 2, 2, 0, ARG_INT|ARG_MAGIC|SP_SESSL, |
|
sp_cf_gen, "( OLcfgOvAt:1.2 NAME 'olcSpSessionlog' " |
|
"DESC 'Session log size in ops' " |
|
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, |
|
{ NULL, NULL, 0, 0, 0, ARG_IGNORED } |
|
}; |
|
|
|
static ConfigOCs spocs[] = { |
|
{ "( OLcfgOvOc:1.1 " |
|
"NAME 'olcSyncProvConfig' " |
|
"DESC 'SyncRepl Provider configuration' " |
|
"SUP olcOverlayConfig " |
|
"MAY ( olcSpCheckpoint $ olcSpSessionlog ) )", |
|
Cft_Overlay, spcfg }, |
|
{ NULL, 0, NULL } |
|
}; |
|
|
static int |
static int |
syncprov_db_config( |
sp_cf_gen(ConfigArgs *c) |
BackendDB *be, |
|
const char *fname, |
|
int lineno, |
|
int argc, |
|
char **argv |
|
) |
|
{ |
{ |
slap_overinst *on = (slap_overinst *)be->bd_info; |
slap_overinst *on = (slap_overinst *)c->bi; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
|
int rc = 0; |
|
|
if ( strcasecmp( argv[ 0 ], "syncprov-checkpoint" ) == 0 ) { |
if ( c->op == SLAP_CONFIG_EMIT ) { |
if ( argc != 3 ) { |
switch ( c->type ) { |
fprintf( stderr, "%s: line %d: wrong number of arguments in " |
case SP_CHKPT: |
"\"syncprov-checkpoint <ops> <minutes>\"\n", fname, lineno ); |
if ( si->si_chkops || si->si_chktime ) { |
return -1; |
struct berval bv; |
|
bv.bv_len = sprintf( c->msg, "%d %d", |
|
si->si_chkops, si->si_chktime ); |
|
bv.bv_val = c->msg; |
|
value_add_one( &c->rvalue_vals, &bv ); |
|
} else { |
|
rc = 1; |
|
} |
|
break; |
|
case SP_SESSL: |
|
if ( si->si_logs ) { |
|
c->value_int = si->si_logs->sl_size; |
|
} else { |
|
rc = 1; |
|
} |
|
break; |
} |
} |
si->si_chkops = atoi( argv[1] ); |
return rc; |
si->si_chktime = atoi( argv[2] ) * 60; |
} else if ( c->op == LDAP_MOD_DELETE ) { |
return 0; |
switch ( c->type ) { |
|
case SP_CHKPT: |
} else if ( strcasecmp( argv[0], "syncprov-sessionlog" ) == 0 ) { |
si->si_chkops = 0; |
sessionlog *sl; |
si->si_chktime = 0; |
int size; |
break; |
if ( argc != 2 ) { |
case SP_SESSL: |
fprintf( stderr, "%s: line %d: wrong number of arguments in " |
if ( si->si_logs ) |
"\"syncprov-sessionlog <size>\"\n", fname, lineno ); |
si->si_logs->sl_size = 0; |
return -1; |
else |
|
rc = LDAP_NO_SUCH_ATTRIBUTE; |
|
break; |
} |
} |
size = atoi( argv[1] ); |
return rc; |
|
} |
|
switch ( c->type ) { |
|
case SP_CHKPT: |
|
si->si_chkops = atoi( c->argv[1] ); |
|
si->si_chktime = atoi( c->argv[2] ) * 60; |
|
break; |
|
case SP_SESSL: { |
|
sessionlog *sl; |
|
int size = c->value_int; |
|
|
if ( size < 0 ) { |
if ( size < 0 ) { |
fprintf( stderr, |
sprintf( c->msg, "%s size %d is negative", |
"%s: line %d: session log size %d is negative\n", |
c->argv[0], size ); |
fname, lineno, size ); |
Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); |
return -1; |
return ARG_BAD_CONF; |
} |
} |
sl = si->si_logs; |
sl = si->si_logs; |
if ( !sl ) { |
if ( !sl ) { |
Line 2042 syncprov_db_config(
|
Line 2094 syncprov_db_config(
|
si->si_logs = sl; |
si->si_logs = sl; |
} |
} |
sl->sl_size = size; |
sl->sl_size = size; |
return 0; |
} |
|
break; |
} |
} |
|
return rc; |
return SLAP_CONF_UNKNOWN; |
|
} |
} |
|
|
/* Cheating - we have no thread pool context for these functions, |
/* Cheating - we have no thread pool context for these functions, |
Line 2338 syncprov_init()
|
Line 2390 syncprov_init()
|
SLAP_CTRL_HIDE|SLAP_CTRL_SEARCH, NULL, |
SLAP_CTRL_HIDE|SLAP_CTRL_SEARCH, NULL, |
syncprov_parseCtrl, &slap_cids.sc_LDAPsync ); |
syncprov_parseCtrl, &slap_cids.sc_LDAPsync ); |
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
fprintf( stderr, "Failed to register control %d\n", rc ); |
Debug( LDAP_DEBUG_ANY, |
|
"syncprov_init: Failed to register control %d\n", rc, 0, 0 ); |
return rc; |
return rc; |
} |
} |
|
|
syncprov.on_bi.bi_type = "syncprov"; |
syncprov.on_bi.bi_type = "syncprov"; |
syncprov.on_bi.bi_db_init = syncprov_db_init; |
syncprov.on_bi.bi_db_init = syncprov_db_init; |
syncprov.on_bi.bi_db_config = syncprov_db_config; |
|
syncprov.on_bi.bi_db_destroy = syncprov_db_destroy; |
syncprov.on_bi.bi_db_destroy = syncprov_db_destroy; |
syncprov.on_bi.bi_db_open = syncprov_db_open; |
syncprov.on_bi.bi_db_open = syncprov_db_open; |
syncprov.on_bi.bi_db_close = syncprov_db_close; |
syncprov.on_bi.bi_db_close = syncprov_db_close; |
Line 2361 syncprov_init()
|
Line 2413 syncprov_init()
|
syncprov.on_bi.bi_extended = syncprov_op_extended; |
syncprov.on_bi.bi_extended = syncprov_op_extended; |
syncprov.on_bi.bi_operational = syncprov_operational; |
syncprov.on_bi.bi_operational = syncprov_operational; |
|
|
|
syncprov.on_bi.bi_cf_ocs = spocs; |
|
|
|
rc = config_register_schema( spcfg, spocs ); |
|
if ( rc ) return rc; |
|
|
return overlay_register( &syncprov ); |
return overlay_register( &syncprov ); |
} |
} |
|
|