op->o_tag = LDAP_REQ_MODIFY;
op->orm_modlist = modlist;
op->o_bd->be_modify( op, &sreply );
- slap_mods_free( modlist );
+ slap_mods_free( modlist, 1 );
} else if ( rc == LDAP_REFERRAL ||
rc == LDAP_NO_SUCH_OBJECT ) {
syncrepl_add_glue( op, e );
vals[1].bv_val = NULL;
vals[1].bv_len = 0;
mod.sml_op = LDAP_MOD_DELETE;
+ mod.sml_flags = 0;
mod.sml_desc = ad_queryid;
mod.sml_type = ad_queryid->ad_cname;
mod.sml_values = vals;
slap_overinst *on = si->on;
cache_manager *cm = on->on_bi.bi_private;
query_manager* qm = cm->qm;
- int i;
int return_val = 0;
Entry *e;
struct berval crp_uuid;
(*new_attrs)[i].an_name = attrs[i].an_name;
(*new_attrs)[i].an_desc = attrs[i].an_desc;
}
- (*new_attrs)[count].an_name.bv_val = NULL;
- (*new_attrs)[count].an_name.bv_len = 0;
+ BER_BVZERO( &(*new_attrs)[count].an_name );
alluser = an_find(*new_attrs, &AllUser);
allop = an_find(*new_attrs, &AllOper);
}
}
}
+/* NOTE: this is a quick workaround to let pcache minimally interact
+ * with pagedResults. A more articulated solutions would be to
+ * perform the remote query without control and cache all results,
+ * performing the pagedResults search only within the client
+ * and the proxy. This requires pcache to understand pagedResults. */
+static int
+proxy_cache_chk_controls(
+ Operation *op,
+ SlapReply *rs )
+{
+ const char *non = "";
+ const char *stripped = "";
+
+ switch( op->o_pagedresults ) {
+ case SLAP_CONTROL_NONCRITICAL:
+ non = "non-";
+ stripped = "; stripped";
+ /* fallthru */
+
+ case SLAP_CONTROL_CRITICAL:
+ Debug( LDAP_DEBUG_ANY, "%s: "
+ "%scritical pagedResults control "
+ "disabled with proxy cache%s.\n",
+ op->o_log_prefix, non, stripped );
+
+ slap_remove_control( op, rs, slap_cids.sc_pagedResults, NULL );
+ break;
+
+ default:
+ rs->sr_err = SLAP_CB_CONTINUE;
+ break;
+ }
+
+ return rs->sr_err;
+}
+
static int
proxy_cache_search(
Operation *op,
int i = -1;
AttributeName *filter_attrs = NULL;
- AttributeName *new_attrs = NULL;
Query query;
Debug( LDAP_DEBUG_ANY, "query template of incoming query = %s\n",
tempstr.bv_val, 0, 0 );
+ /* FIXME: cannot cache/answer requests with pagedResults control */
+
+
/* find attr set */
attr_set = get_attr_set(op->ors_attrs, qm, cm->numattrsets);
cache_manager *cm = on->on_bi.bi_private;
query_manager *qm = cm->qm;
Connection conn = {0};
- char opbuf[OPERATION_BUFFER_SIZE];
+ OperationBuffer opbuf;
Operation *op;
SlapReply rs = {REP_RESULT};
int i, return_val, pause = 1;
QueryTemplate* templ;
- op = (Operation *)opbuf;
+ op = (Operation *) &opbuf;
connection_fake_init( &conn, op, ctx );
op->o_bd = &cm->db;
"DESC 'Filter template, attrset, and cache TTL' "
"SYNTAX OMsDirectoryString )", NULL, NULL },
{ "response-callback", "head|tail(default)",
- 2, 2, 0, ARG_MAGIC|ARG_STRING|PC_RESP, pc_cf_gen,
+ 2, 2, 0, ARG_MAGIC|PC_RESP, pc_cf_gen,
"( OLcfgOvAt:2.4 NAME 'olcProxyResponseCB' "
"DESC 'Response callback position in overlay stack' "
"SYNTAX OMsDirectoryString )", NULL, NULL },
break;
case PC_TEMP:
for (i=0; i<cm->numtemplates; i++) {
- bv.bv_len = sprintf( c->msg, " %d %d",
+ bv.bv_len = sprintf( c->msg, " %d %ld",
qm->templates[i].attr_set_index,
qm->templates[i].ttl );
bv.bv_len += qm->templates[i].querystr.bv_len + 2;
break;
case PC_RESP:
if ( cm->response_cb == PCACHE_RESPONSE_CB_HEAD ) {
- bv.bv_val = "head";
- bv.bv_len = STRLENOF("head");
+ BER_BVSTR( &bv, "head" );
} else {
- bv.bv_val = "tail";
- bv.bv_len = STRLENOF("tail");
+ BER_BVSTR( &bv, "tail" );
}
value_add_one( &c->rvalue_vals, &bv );
break;
Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return( 1 );
}
- cm->db.bd_info = backend_info( c->argv[1] );
- if ( !cm->db.bd_info ) {
+ if ( !backend_db_init( c->argv[1], &cm->db )) {
sprintf( c->msg, "unknown backend type" );
Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
return( 1 );
}
- if ( cm->db.bd_info->bi_db_init( &cm->db ) ) {
- sprintf( c->msg, "backend %s init failed", c->argv[1] );
- Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
- return( 1 );
- }
-
- /* This type is in use, needs to be opened */
- cm->db.bd_info->bi_nDB++;
-
cm->max_entries = atoi( c->argv[2] );
cm->num_entries_limit = atoi( c->argv[4] );
slap_overinst *on = (slap_overinst *)be->bd_info;
cache_manager *cm = on->on_bi.bi_private;
int rc = 0;
- int i;
/* need to inherit something from the original database... */
cm->db.be_def_limit = be->be_def_limit;
slap_overinst *on = (slap_overinst *)be->bd_info;
cache_manager *cm = on->on_bi.bi_private;
query_manager *qm = cm->qm;
- int rc = 0;
- if ( cm->db.bd_info->bi_db_destroy ) {
- rc = cm->db.bd_info->bi_db_destroy( &cm->db );
- }
- ldap_pvt_thread_mutex_destroy(&qm->lru_mutex);
- ldap_pvt_thread_mutex_destroy(&cm->cache_mutex);
- ldap_pvt_thread_mutex_destroy(&cm->remove_mutex);
+ /* cleanup stuff inherited from the original database... */
+ cm->db.be_suffix = NULL;
+ cm->db.be_nsuffix = NULL;
+ BER_BVZERO( &cm->db.be_rootdn );
+ BER_BVZERO( &cm->db.be_rootndn );
+ BER_BVZERO( &cm->db.be_rootpw );
+ /* FIXME: there might be more... */
+
+ backend_destroy_one( &cm->db, 0 );
+
+ ldap_pvt_thread_mutex_destroy( &qm->lru_mutex );
+ ldap_pvt_thread_mutex_destroy( &cm->cache_mutex );
+ ldap_pvt_thread_mutex_destroy( &cm->remove_mutex );
free( qm );
free( cm );
- return rc;
+
+ return 0;
}
static slap_overinst proxy_cache;
return code;
}
- proxy_cache.on_bi.bi_type = "proxycache";
+ 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_destroy = proxy_cache_destroy;
proxy_cache.on_bi.bi_op_search = proxy_cache_search;
+ proxy_cache.on_bi.bi_chk_controls = proxy_cache_chk_controls;
+
proxy_cache.on_bi.bi_cf_ocs = pcocs;
code = config_register_schema( pccfg, pcocs );