version 1.41.2.10, 2005/11/03 20:26:11
|
version 1.41.2.11, 2005/11/26 23:54:51
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/pcache.c,v 1.62 2005/11/03 19:38:51 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/pcache.c,v 1.41.2.10 2005/11/03 20:26:11 kurt Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2003-2005 The OpenLDAP Foundation. |
* Copyright 2003-2005 The OpenLDAP Foundation. |
Line 68 typedef struct query_template_s {
|
Line 68 typedef struct query_template_s {
|
CachedQuery* query_last; /* oldest query cached for the template */ |
CachedQuery* query_last; /* oldest query cached for the template */ |
|
|
int no_of_queries; /* Total number of queries in 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 */ |
ldap_pvt_thread_rdwr_t t_rwlock; /* Rd/wr lock for accessing queries in the template */ |
} QueryTemplate; |
} QueryTemplate; |
|
|
Line 78 typedef struct query_template_s {
|
Line 78 typedef struct query_template_s {
|
*/ |
*/ |
|
|
struct attr_set { |
struct attr_set { |
|
unsigned flags; |
|
#define PC_CONFIGURED (0x1) |
|
#define PC_REFERENCED (0x2) |
AttributeName* attrs; /* specifies the set */ |
AttributeName* attrs; /* specifies the set */ |
int count; /* number of attributes */ |
int count; /* number of attributes */ |
int* ID_array; /* array of indices of supersets of 'attrs' */ |
int* ID_array; /* array of indices of supersets of 'attrs' */ |
Line 124 typedef struct cache_manager_s {
|
Line 127 typedef struct cache_manager_s {
|
#define PCACHE_RESPONSE_CB_HEAD 0 |
#define PCACHE_RESPONSE_CB_HEAD 0 |
#define PCACHE_RESPONSE_CB_TAIL 1 |
#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; |
int cc_paused; |
void *cc_arg; |
void *cc_arg; |
|
|
Line 730 static void cache_replacement(query_mana
|
Line 733 static void cache_replacement(query_mana
|
Debug ( LDAP_DEBUG_ANY, |
Debug ( LDAP_DEBUG_ANY, |
"Cache replacement invoked without " |
"Cache replacement invoked without " |
"any query in LRU list\n", 0, 0, 0 ); |
"any query in LRU list\n", 0, 0, 0 ); |
|
ldap_pvt_thread_mutex_unlock(&qm->lru_mutex); |
return; |
return; |
} |
} |
|
|
Line 1082 cache_entries(
|
Line 1086 cache_entries(
|
} |
} |
|
|
static int |
static int |
proxy_cache_response( |
pcache_response( |
Operation *op, |
Operation *op, |
SlapReply *rs ) |
SlapReply *rs ) |
{ |
{ |
Line 1117 proxy_cache_response(
|
Line 1121 proxy_cache_response(
|
} |
} |
} |
} |
|
|
if (rs->sr_attrs != op->ors_attrs ) { |
if ( rs->sr_attrs != op->ors_attrs ) { |
op->o_tmpfree( rs->sr_attrs, op->o_tmpmemctx ); |
op->o_tmpfree( rs->sr_attrs, op->o_tmpmemctx ); |
} |
} |
rs->sr_attrs = si->query.save_attrs; |
|
op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx ); |
if ( si->query.save_attrs != NULL ) { |
op->ors_attrs = si->query.save_attrs; |
rs->sr_attrs = si->query.save_attrs; |
si->query.save_attrs = NULL; |
op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx ); |
|
op->ors_attrs = si->query.save_attrs; |
|
si->query.save_attrs = NULL; |
|
} |
|
|
} else if ( rs->sr_type == REP_RESULT ) { |
} else if ( rs->sr_type == REP_RESULT ) { |
if ( si->count && cache_entries( op, rs, &uuid ) == 0 ) { |
if ( si->count && cache_entries( op, rs, &uuid ) == 0 ) { |
Line 1211 add_filter_attrs(
|
Line 1218 add_filter_attrs(
|
* performing the pagedResults search only within the client |
* performing the pagedResults search only within the client |
* and the proxy. This requires pcache to understand pagedResults. */ |
* and the proxy. This requires pcache to understand pagedResults. */ |
static int |
static int |
proxy_cache_chk_controls( |
pcache_chk_controls( |
Operation *op, |
Operation *op, |
SlapReply *rs ) |
SlapReply *rs ) |
{ |
{ |
Line 1242 proxy_cache_chk_controls(
|
Line 1249 proxy_cache_chk_controls(
|
} |
} |
|
|
static int |
static int |
proxy_cache_search( |
pcache_op_search( |
Operation *op, |
Operation *op, |
SlapReply *rs ) |
SlapReply *rs ) |
{ |
{ |
Line 1370 proxy_cache_search(
|
Line 1377 proxy_cache_search(
|
add_filter_attrs(op, &op->ors_attrs, query.attrs, filter_attrs); |
add_filter_attrs(op, &op->ors_attrs, query.attrs, filter_attrs); |
|
|
cb = op->o_tmpalloc( sizeof(*cb) + sizeof(*si), op->o_tmpmemctx); |
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_cleanup = NULL; |
cb->sc_private = (cb+1); |
cb->sc_private = (cb+1); |
si = cb->sc_private; |
si = cb->sc_private; |
Line 1710 pc_cfadd( Operation *op, SlapReply *rs,
|
Line 1717 pc_cfadd( Operation *op, SlapReply *rs,
|
static int |
static int |
pc_cf_gen( ConfigArgs *c ) |
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; |
cache_manager* cm = on->on_bi.bi_private; |
query_manager* qm = cm->qm; |
query_manager* qm = cm->qm; |
QueryTemplate* temp; |
QueryTemplate* temp; |
AttributeName* attr_name; |
AttributeName* attr_name; |
AttributeName* attrarray; |
AttributeName* attrarray; |
const char* text=NULL; |
const char* text=NULL; |
int i, num, rc = 0; |
int i, num, rc = 0; |
char *ptr; |
char *ptr; |
|
unsigned long t; |
|
|
if ( c->op == SLAP_CONFIG_EMIT ) { |
if ( c->op == SLAP_CONFIG_EMIT ) { |
struct berval bv; |
struct berval bv; |
switch( c->type ) { |
switch( c->type ) { |
case PC_MAIN: |
case PC_MAIN: |
bv.bv_len = sprintf( 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->db.bd_info->bi_type, cm->max_entries, cm->numattrsets, |
cm->num_entries_limit, cm->cc_period ); |
cm->num_entries_limit, cm->cc_period ); |
bv.bv_val = c->msg; |
bv.bv_val = c->msg; |
Line 1734 pc_cf_gen( ConfigArgs *c )
|
Line 1742 pc_cf_gen( ConfigArgs *c )
|
for (i=0; i<cm->numattrsets; i++) { |
for (i=0; i<cm->numattrsets; i++) { |
if ( !qm->attr_sets[i].count ) continue; |
if ( !qm->attr_sets[i].count ) continue; |
|
|
bv.bv_len = sprintf( c->msg, "%d", i ); |
bv.bv_len = snprintf( c->msg, sizeof( c->msg ), "%d", i ); |
|
|
/* count the attr length */ |
/* count the attr length */ |
for ( attr_name = qm->attr_sets[i].attrs; |
for ( attr_name = qm->attr_sets[i].attrs; |
Line 1755 pc_cf_gen( ConfigArgs *c )
|
Line 1763 pc_cf_gen( ConfigArgs *c )
|
break; |
break; |
case PC_TEMP: |
case PC_TEMP: |
for (i=0; i<cm->numtemplates; i++) { |
for (i=0; i<cm->numtemplates; i++) { |
bv.bv_len = sprintf( c->msg, " %d %ld", |
bv.bv_len = snprintf( c->msg, sizeof( c->msg ), " %d %ld", |
qm->templates[i].attr_set_index, |
qm->templates[i].attr_set_index, |
qm->templates[i].ttl ); |
qm->templates[i].ttl ); |
bv.bv_len += qm->templates[i].querystr.bv_len + 2; |
bv.bv_len += qm->templates[i].querystr.bv_len + 2; |
Line 1793 pc_cf_gen( ConfigArgs *c )
|
Line 1801 pc_cf_gen( ConfigArgs *c )
|
|
|
switch( c->type ) { |
switch( c->type ) { |
case PC_MAIN: |
case PC_MAIN: |
cm->numattrsets = atoi( c->argv[3] ); |
if ( cm->numattrsets > 0 ) { |
|
snprintf( c->msg, sizeof( c->msg ), "\"proxycache\" directive already provided" ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
|
return( 1 ); |
|
} |
|
|
|
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 ); |
|
} |
|
if ( cm->numattrsets <= 0 ) { |
|
snprintf( c->msg, sizeof( c->msg ), "numattrsets (arg #3) must be positive" ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
|
return( 1 ); |
|
} |
if ( cm->numattrsets > MAX_ATTR_SETS ) { |
if ( cm->numattrsets > MAX_ATTR_SETS ) { |
sprintf( c->msg, "numattrsets must be <= %d", MAX_ATTR_SETS ); |
snprintf( c->msg, sizeof( c->msg ), "numattrsets (arg #3) must be <= %d", MAX_ATTR_SETS ); |
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 ); |
return( 1 ); |
} |
} |
|
|
if ( !backend_db_init( c->argv[1], &cm->db )) { |
if ( !backend_db_init( c->argv[1], &cm->db )) { |
sprintf( c->msg, "unknown backend type" ); |
snprintf( c->msg, sizeof( c->msg ), "unknown backend type (arg #1)" ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
|
return( 1 ); |
|
} |
|
|
|
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 ); |
|
} |
|
if ( cm->max_entries <= 0 ) { |
|
snprintf( c->msg, sizeof( c->msg ), "max entries (arg #2) must be positive.\n" ); |
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 ); |
return( 1 ); |
} |
} |
cm->max_entries = atoi( c->argv[2] ); |
|
|
|
cm->num_entries_limit = atoi( c->argv[4] ); |
if ( lutil_atoi( &cm->num_entries_limit, c->argv[4] ) != 0 ) { |
cm->cc_period = atoi( c->argv[5] ); |
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 ); |
|
} |
|
if ( cm->num_entries_limit <= 0 ) { |
|
snprintf( c->msg, sizeof( c->msg ), "entry limit (arg #4) must be positive" ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
|
return( 1 ); |
|
} |
|
if ( cm->num_entries_limit > cm->max_entries ) { |
|
snprintf( c->msg, sizeof( c->msg ), "entry limit (arg #4) must be less than max entries %d (arg #2)", cm->max_entries ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
|
return( 1 ); |
|
} |
|
|
|
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 ); |
|
} |
|
cm->cc_period = (time_t)t; |
Debug( LDAP_DEBUG_TRACE, |
Debug( LDAP_DEBUG_TRACE, |
"Total # of attribute sets to be cached = %d\n", |
"Total # of attribute sets to be cached = %d.\n", |
cm->numattrsets, 0, 0 ); |
cm->numattrsets, 0, 0 ); |
qm->attr_sets = ( struct attr_set * )ch_malloc( cm->numattrsets * |
qm->attr_sets = ( struct attr_set * )ch_calloc( cm->numattrsets, |
sizeof( struct attr_set )); |
sizeof( struct attr_set ) ); |
for ( i = 0; i < cm->numattrsets; i++ ) { |
|
qm->attr_sets[i].attrs = NULL; |
|
} |
|
break; |
break; |
case PC_ATTR: |
case PC_ATTR: |
num = atoi( c->argv[1] ); |
if ( cm->numattrsets == 0 ) { |
if (num >= cm->numattrsets) { |
snprintf( c->msg, sizeof( c->msg ), "\"proxycache\" directive not provided yet" ); |
sprintf( c->msg, "attrset index out of bounds" ); |
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 ); |
|
} |
|
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 ); |
|
return( 1 ); |
|
} |
|
|
|
if ( num < 0 || num >= cm->numattrsets ) { |
|
snprintf( c->msg, sizeof( c->msg ), "attrset index %d out of bounds (must be %s%d)", |
|
num, cm->numattrsets > 1 ? "0->" : "", cm->numattrsets - 1 ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
return 1; |
return 1; |
} |
} |
if ( c->argv[2] && strcmp( c->argv[2], "*" ) ) { |
qm->attr_sets[num].flags |= PC_CONFIGURED; |
|
if ( c->argc > 2 && strcmp( c->argv[2], "*" ) ) { |
qm->attr_sets[num].count = c->argc - 2; |
qm->attr_sets[num].count = c->argc - 2; |
qm->attr_sets[num].attrs = (AttributeName*)ch_malloc( |
qm->attr_sets[num].attrs = (AttributeName*)ch_malloc( |
(c->argc-1) * sizeof( AttributeName )); |
(c->argc-1) * sizeof( AttributeName )); |
Line 1833 pc_cf_gen( ConfigArgs *c )
|
Line 1901 pc_cf_gen( ConfigArgs *c )
|
ber_str2bv( c->argv[i], 0, 1, &attr_name->an_name); |
ber_str2bv( c->argv[i], 0, 1, &attr_name->an_name); |
attr_name->an_desc = NULL; |
attr_name->an_desc = NULL; |
if ( slap_bv2ad( &attr_name->an_name, |
if ( slap_bv2ad( &attr_name->an_name, |
&attr_name->an_desc, &text )) { |
&attr_name->an_desc, &text ) ) |
|
{ |
strcpy( c->msg, text ); |
strcpy( c->msg, text ); |
Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); |
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
ch_free( qm->attr_sets[num].attrs ); |
ch_free( qm->attr_sets[num].attrs ); |
qm->attr_sets[num].attrs = NULL; |
qm->attr_sets[num].attrs = NULL; |
qm->attr_sets[num].count = 0; |
qm->attr_sets[num].count = 0; |
Line 1849 pc_cf_gen( ConfigArgs *c )
|
Line 1918 pc_cf_gen( ConfigArgs *c )
|
} |
} |
break; |
break; |
case PC_TEMP: |
case PC_TEMP: |
if (( i = atoi( c->argv[2] )) >= cm->numattrsets ) { |
if ( cm->numattrsets == 0 ) { |
sprintf( c->msg, "template index invalid" ); |
snprintf( c->msg, sizeof( c->msg ), "\"proxycache\" directive not provided yet" ); |
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 ); |
|
} |
|
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 ); |
|
return( 1 ); |
|
} |
|
|
|
if ( i < 0 || i >= cm->numattrsets ) { |
|
snprintf( c->msg, sizeof( c->msg ), "template index %d invalid (%s%d)", |
|
i, cm->numattrsets > 1 ? "0->" : "", cm->numattrsets - 1 ); |
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); |
return 1; |
return 1; |
} |
} |
num = cm->numtemplates; |
num = cm->numtemplates; |
Line 1862 pc_cf_gen( ConfigArgs *c )
|
Line 1944 pc_cf_gen( ConfigArgs *c )
|
temp = qm->templates + num; |
temp = qm->templates + num; |
ldap_pvt_thread_rdwr_init( &temp->t_rwlock ); |
ldap_pvt_thread_rdwr_init( &temp->t_rwlock ); |
temp->query = temp->query_last = NULL; |
temp->query = temp->query_last = NULL; |
temp->ttl = atoi( c->argv[3] ); |
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 ); |
|
} |
|
temp->ttl = (time_t)t; |
|
|
temp->no_of_queries = 0; |
temp->no_of_queries = 0; |
|
|
ber_str2bv( c->argv[1], 0, 1, &temp->querystr ); |
ber_str2bv( c->argv[1], 0, 1, &temp->querystr ); |
Line 1870 pc_cf_gen( ConfigArgs *c )
|
Line 1959 pc_cf_gen( ConfigArgs *c )
|
Debug( LDAP_DEBUG_TRACE, " query template: %s\n", |
Debug( LDAP_DEBUG_TRACE, " query template: %s\n", |
temp->querystr.bv_val, 0, 0 ); |
temp->querystr.bv_val, 0, 0 ); |
temp->attr_set_index = i; |
temp->attr_set_index = i; |
|
qm->attr_sets[i].flags |= PC_REFERENCED; |
Debug( LDAP_DEBUG_TRACE, " attributes: \n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_TRACE, " attributes: \n", 0, 0, 0 ); |
if ( ( attrarray = qm->attr_sets[i].attrs ) != NULL ) { |
if ( ( attrarray = qm->attr_sets[i].attrs ) != NULL ) { |
for ( i=0; attrarray[i].an_name.bv_val; i++ ) |
for ( i=0; attrarray[i].an_name.bv_val; i++ ) |
Line 1888 pc_cf_gen( ConfigArgs *c )
|
Line 1978 pc_cf_gen( ConfigArgs *c )
|
cm->response_cb = PCACHE_RESPONSE_CB_TAIL; |
cm->response_cb = PCACHE_RESPONSE_CB_TAIL; |
|
|
} else { |
} else { |
sprintf( c->msg, "unknown specifier" ); |
snprintf( c->msg, sizeof( c->msg ), "unknown specifier" ); |
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; |
return 1; |
} |
} |
break; |
break; |
Line 1898 pc_cf_gen( ConfigArgs *c )
|
Line 1988 pc_cf_gen( ConfigArgs *c )
|
} |
} |
|
|
static int |
static int |
proxy_cache_config( |
pcache_db_config( |
BackendDB *be, |
BackendDB *be, |
const char *fname, |
const char *fname, |
int lineno, |
int lineno, |
Line 1917 proxy_cache_config(
|
Line 2007 proxy_cache_config(
|
} |
} |
|
|
static int |
static int |
proxy_cache_init( |
pcache_db_init( |
BackendDB *be |
BackendDB *be |
) |
) |
{ |
{ |
Line 1962 proxy_cache_init(
|
Line 2052 proxy_cache_init(
|
} |
} |
|
|
static int |
static int |
proxy_cache_open( |
pcache_db_open( |
BackendDB *be |
BackendDB *be |
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *)be->bd_info; |
slap_overinst *on = (slap_overinst *)be->bd_info; |
cache_manager *cm = on->on_bi.bi_private; |
cache_manager *cm = on->on_bi.bi_private; |
int rc = 0; |
query_manager* qm = cm->qm; |
|
int i, ncf = 0, rf = 0, nrf = 0, rc = 0; |
|
|
|
/* check attr sets */ |
|
for ( i = 0; i < cm->numattrsets; i++) { |
|
if ( !( qm->attr_sets[i].flags & PC_CONFIGURED ) ) { |
|
if ( qm->attr_sets[i].flags & PC_REFERENCED ) { |
|
Debug( LDAP_DEBUG_ANY, "pcache: attr set #%d not configured but referenced.\n", i, 0, 0 ); |
|
rf++; |
|
|
|
} else { |
|
Debug( LDAP_DEBUG_ANY, "pcache: warning, attr set #%d not configured.\n", i, 0, 0 ); |
|
} |
|
ncf++; |
|
|
|
} else if ( !( qm->attr_sets[i].flags & PC_REFERENCED ) ) { |
|
Debug( LDAP_DEBUG_ANY, "pcache: attr set #%d configured but not referenced.\n", i, 0, 0 ); |
|
nrf++; |
|
} |
|
} |
|
|
|
if ( ncf || rf || nrf ) { |
|
Debug( LDAP_DEBUG_ANY, "pcache: warning, %d attr sets configured but not referenced.\n", nrf, 0, 0 ); |
|
Debug( LDAP_DEBUG_ANY, "pcache: warning, %d attr sets not configured.\n", ncf, 0, 0 ); |
|
Debug( LDAP_DEBUG_ANY, "pcache: %d attr sets not configured but referenced.\n", rf, 0, 0 ); |
|
|
|
if ( rf > 0 ) { |
|
return 1; |
|
} |
|
} |
|
|
/* need to inherit something from the original database... */ |
/* need to inherit something from the original database... */ |
cm->db.be_def_limit = be->be_def_limit; |
cm->db.be_def_limit = be->be_def_limit; |
Line 1990 proxy_cache_open(
|
Line 2109 proxy_cache_open(
|
if ( BER_BVISNULL( &cm->db.be_rootndn ) |
if ( BER_BVISNULL( &cm->db.be_rootndn ) |
|| BER_BVISEMPTY( &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" |
"underlying database of type \"%s\"\n" |
" serving naming context \"%s\"\n" |
" serving naming context \"%s\"\n" |
" has no \"rootdn\", required by \"proxycache\".\n", |
" has no \"rootdn\", required by \"proxycache\".\n", |
Line 2004 proxy_cache_open(
|
Line 2123 proxy_cache_open(
|
} |
} |
|
|
static int |
static int |
proxy_cache_close( |
pcache_db_close( |
BackendDB *be |
BackendDB *be |
) |
) |
{ |
{ |
Line 2046 proxy_cache_close(
|
Line 2165 proxy_cache_close(
|
} |
} |
|
|
static int |
static int |
proxy_cache_destroy( |
pcache_db_destroy( |
BackendDB *be |
BackendDB *be |
) |
) |
{ |
{ |
Line 2062 proxy_cache_destroy(
|
Line 2181 proxy_cache_destroy(
|
BER_BVZERO( &cm->db.be_rootpw ); |
BER_BVZERO( &cm->db.be_rootpw ); |
/* FIXME: there might be more... */ |
/* FIXME: there might be more... */ |
|
|
backend_destroy_one( &cm->db, 0 ); |
if ( cm->db.be_private != NULL ) { |
|
backend_destroy_one( &cm->db, 0 ); |
|
} |
|
|
ldap_pvt_thread_mutex_destroy( &qm->lru_mutex ); |
ldap_pvt_thread_mutex_destroy( &qm->lru_mutex ); |
ldap_pvt_thread_mutex_destroy( &cm->cache_mutex ); |
ldap_pvt_thread_mutex_destroy( &cm->cache_mutex ); |
Line 2073 proxy_cache_destroy(
|
Line 2194 proxy_cache_destroy(
|
return 0; |
return 0; |
} |
} |
|
|
static slap_overinst proxy_cache; |
static slap_overinst pcache; |
|
|
int pcache_init() |
int pcache_initialize() |
{ |
{ |
LDAPAttributeType *at; |
LDAPAttributeType *at; |
int code; |
int code; |
Line 2085 int pcache_init()
|
Line 2206 int pcache_init()
|
LDAP_SCHEMA_ALLOW_ALL ); |
LDAP_SCHEMA_ALLOW_ALL ); |
if ( !at ) { |
if ( !at ) { |
Debug( LDAP_DEBUG_ANY, |
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 ); |
ldap_scherr2str(code), err, 0 ); |
return code; |
return code; |
} |
} |
Line 2096 int pcache_init()
|
Line 2217 int pcache_init()
|
ldap_memfree( at ); |
ldap_memfree( at ); |
if ( code ) { |
if ( code ) { |
Debug( LDAP_DEBUG_ANY, |
Debug( LDAP_DEBUG_ANY, |
"pcache_init: at_add failed %s %s\n", |
"pcache_initialize: at_add failed %s %s\n", |
scherr2str(code), err, 0 ); |
scherr2str(code), err, 0 ); |
return code; |
return code; |
} |
} |
|
|
proxy_cache.on_bi.bi_type = "pcache"; |
pcache.on_bi.bi_type = "pcache"; |
proxy_cache.on_bi.bi_db_init = proxy_cache_init; |
pcache.on_bi.bi_db_init = pcache_db_init; |
proxy_cache.on_bi.bi_db_config = proxy_cache_config; |
pcache.on_bi.bi_db_config = pcache_db_config; |
proxy_cache.on_bi.bi_db_open = proxy_cache_open; |
pcache.on_bi.bi_db_open = pcache_db_open; |
proxy_cache.on_bi.bi_db_close = proxy_cache_close; |
pcache.on_bi.bi_db_close = pcache_db_close; |
proxy_cache.on_bi.bi_db_destroy = proxy_cache_destroy; |
pcache.on_bi.bi_db_destroy = pcache_db_destroy; |
proxy_cache.on_bi.bi_op_search = proxy_cache_search; |
|
|
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 ); |
code = config_register_schema( pccfg, pcocs ); |
if ( code ) return code; |
if ( code ) return code; |
|
|
return overlay_register( &proxy_cache ); |
return overlay_register( &pcache ); |
} |
} |
|
|
#if SLAPD_OVER_PROXYCACHE == SLAPD_MOD_DYNAMIC |
#if SLAPD_OVER_PROXYCACHE == SLAPD_MOD_DYNAMIC |
int init_module(int argc, char *argv[]) { |
int init_module(int argc, char *argv[]) { |
return pcache_init(); |
return pcache_initialize(); |
} |
} |
#endif |
#endif |
|
|