CachedQuery* query_last; /* oldest query cached for the template */
int no_of_queries; /* Total number of queries in the template */
- long ttl; /* TTL for the queries of this template */
+ time_t ttl; /* TTL for the queries of this template */
ldap_pvt_thread_rdwr_t t_rwlock; /* Rd/wr lock for accessing queries in the template */
} QueryTemplate;
#define PCACHE_RESPONSE_CB_HEAD 0
#define PCACHE_RESPONSE_CB_TAIL 1
- int cc_period; /* interval between successive consistency checks (sec) */
+ time_t cc_period; /* interval between successive consistency checks (sec) */
int cc_paused;
void *cc_arg;
}
static int
-proxy_cache_response(
+pcache_response(
Operation *op,
SlapReply *rs )
{
* performing the pagedResults search only within the client
* and the proxy. This requires pcache to understand pagedResults. */
static int
-proxy_cache_chk_controls(
+pcache_chk_controls(
Operation *op,
SlapReply *rs )
{
}
static int
-proxy_cache_search(
+pcache_op_search(
Operation *op,
SlapReply *rs )
{
add_filter_attrs(op, &op->ors_attrs, query.attrs, filter_attrs);
cb = op->o_tmpalloc( sizeof(*cb) + sizeof(*si), op->o_tmpmemctx);
- cb->sc_response = proxy_cache_response;
+ cb->sc_response = pcache_response;
cb->sc_cleanup = NULL;
cb->sc_private = (cb+1);
si = cb->sc_private;
static int
pc_cf_gen( ConfigArgs *c )
{
- slap_overinst *on = (slap_overinst *)c->bi;
+ slap_overinst *on = (slap_overinst *)c->bi;
cache_manager* cm = on->on_bi.bi_private;
query_manager* qm = cm->qm;
QueryTemplate* temp;
AttributeName* attr_name;
AttributeName* attrarray;
const char* text=NULL;
- int i, num, rc = 0;
- char *ptr, *next;
+ int i, num, rc = 0;
+ char *ptr;
+ unsigned long t;
if ( c->op == SLAP_CONFIG_EMIT ) {
struct berval bv;
switch( c->type ) {
case PC_MAIN:
- bv.bv_len = snprintf( c->msg, sizeof( c->msg ), "%s %d %d %d %d",
+ bv.bv_len = snprintf( c->msg, sizeof( c->msg ), "%s %d %d %d %ld",
cm->db.bd_info->bi_type, cm->max_entries, cm->numattrsets,
cm->num_entries_limit, cm->cc_period );
bv.bv_val = c->msg;
return( 1 );
}
- cm->numattrsets = strtol( c->argv[3], &next, 10 );
- if ( next == c->argv[3] || next[0] != '\0' ) {
+ if ( lutil_atoi( &cm->numattrsets, c->argv[3] ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse num attrsets=\"%s\" (arg #3)",
c->argv[3] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- cm->max_entries = strtol( c->argv[2], &next, 10 );
- if ( next == c->argv[2] || next[ 0 ] != '\0' ) {
+ if ( lutil_atoi( &cm->max_entries, c->argv[2] ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse max entries=\"%s\" (arg #2)",
c->argv[2] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- cm->num_entries_limit = strtol( c->argv[4], &next, 10 );
- if ( next == c->argv[4] || next[ 0 ] != '\0' ) {
+ if ( lutil_atoi( &cm->num_entries_limit, c->argv[4] ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse entry limit=\"%s\" (arg #4)",
c->argv[4] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- cm->cc_period = strtol( c->argv[5], &next, 10 );
- if ( next == c->argv[5] || next[ 0 ] != '\0' ) {
+ if ( lutil_parse_time( c->argv[5], &t ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse period=\"%s\" (arg #5)",
c->argv[5] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- if ( cm->cc_period <= 0 ) {
- snprintf( c->msg, sizeof( c->msg ), "period (arg #5) must be positive" );
- Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
- return( 1 );
- }
-
+ cm->cc_period = (time_t)t;
Debug( LDAP_DEBUG_TRACE,
"Total # of attribute sets to be cached = %d.\n",
cm->numattrsets, 0, 0 );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- num = strtol( c->argv[1], &next, 10 );
- if ( next == c->argv[1] || next[ 0 ] != '\0' ) {
+ if ( lutil_atoi( &num, c->argv[1] ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse attrset #=\"%s\"",
c->argv[1] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- i = strtol( c->argv[2], &next, 10 );
- if ( next == c->argv[2] || next[ 0 ] != '\0' ) {
+ if ( lutil_atoi( &i, c->argv[2] ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse template #=\"%s\"",
c->argv[2] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
temp = qm->templates + num;
ldap_pvt_thread_rdwr_init( &temp->t_rwlock );
temp->query = temp->query_last = NULL;
- temp->ttl = strtol( c->argv[3], &next, 10 );
- if ( next == c->argv[3] || next[ 0 ] != '\0' ) {
+ if ( lutil_parse_time( c->argv[3], &t ) != 0 ) {
snprintf( c->msg, sizeof( c->msg ), "unable to parse template ttl=\"%s\"",
c->argv[3] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
}
- if ( temp->ttl <= 0 ) {
- snprintf( c->msg, sizeof( c->msg ), "template ttl must be positive" );
- Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
- return( 1 );
- }
+ temp->ttl = (time_t)t;
temp->no_of_queries = 0;
}
static int
-proxy_cache_config(
+pcache_db_config(
BackendDB *be,
const char *fname,
int lineno,
}
static int
-proxy_cache_init(
+pcache_db_init(
BackendDB *be
)
{
}
static int
-proxy_cache_open(
+pcache_db_open(
BackendDB *be
)
{
if ( BER_BVISNULL( &cm->db.be_rootndn )
|| BER_BVISEMPTY( &cm->db.be_rootndn ) )
{
- Debug( LDAP_DEBUG_ANY, "proxy_cache_open(): "
+ Debug( LDAP_DEBUG_ANY, "pcache_db_open(): "
"underlying database of type \"%s\"\n"
" serving naming context \"%s\"\n"
" has no \"rootdn\", required by \"proxycache\".\n",
}
static int
-proxy_cache_close(
+pcache_db_close(
BackendDB *be
)
{
}
static int
-proxy_cache_destroy(
+pcache_db_destroy(
BackendDB *be
)
{
return 0;
}
-static slap_overinst proxy_cache;
+static slap_overinst pcache;
-int pcache_init()
+static char *obsolete_names[] = {
+ "proxycache",
+ NULL
+};
+
+int pcache_initialize()
{
LDAPAttributeType *at;
int code;
LDAP_SCHEMA_ALLOW_ALL );
if ( !at ) {
Debug( LDAP_DEBUG_ANY,
- "pcache_init: ldap_str2attributetype failed %s %s\n",
+ "pcache_initialize: ldap_str2attributetype failed %s %s\n",
ldap_scherr2str(code), err, 0 );
return code;
}
ldap_memfree( at );
if ( code ) {
Debug( LDAP_DEBUG_ANY,
- "pcache_init: at_add failed %s %s\n",
+ "pcache_initialize: at_add failed %s %s\n",
scherr2str(code), err, 0 );
return code;
}
- proxy_cache.on_bi.bi_type = "pcache";
- proxy_cache.on_bi.bi_db_init = proxy_cache_init;
- proxy_cache.on_bi.bi_db_config = proxy_cache_config;
- proxy_cache.on_bi.bi_db_open = proxy_cache_open;
- proxy_cache.on_bi.bi_db_close = proxy_cache_close;
- proxy_cache.on_bi.bi_db_destroy = proxy_cache_destroy;
- proxy_cache.on_bi.bi_op_search = proxy_cache_search;
+ pcache.on_bi.bi_type = "pcache";
+ pcache.on_bi.bi_obsolete_names = obsolete_names;
+ pcache.on_bi.bi_db_init = pcache_db_init;
+ pcache.on_bi.bi_db_config = pcache_db_config;
+ pcache.on_bi.bi_db_open = pcache_db_open;
+ pcache.on_bi.bi_db_close = pcache_db_close;
+ pcache.on_bi.bi_db_destroy = pcache_db_destroy;
+
+ pcache.on_bi.bi_op_search = pcache_op_search;
- proxy_cache.on_bi.bi_chk_controls = proxy_cache_chk_controls;
+ pcache.on_bi.bi_chk_controls = pcache_chk_controls;
- proxy_cache.on_bi.bi_cf_ocs = pcocs;
+ pcache.on_bi.bi_cf_ocs = pcocs;
code = config_register_schema( pccfg, pcocs );
if ( code ) return code;
- return overlay_register( &proxy_cache );
+ return overlay_register( &pcache );
}
#if SLAPD_OVER_PROXYCACHE == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
- return pcache_init();
+ return pcache_initialize();
}
#endif