]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/pcache.c
don't search max CSN if don't have a value; try the operational_attrs if entryCSN...
[openldap] / servers / slapd / overlays / pcache.c
index 78549fbe26a80b00badb47ff69c219aeed8ea32d..c2998332fb8f43863fb41621f523f249ab50703a 100644 (file)
@@ -68,7 +68,7 @@ typedef struct query_template_s {
        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;
 
@@ -78,6 +78,9 @@ typedef struct query_template_s {
  */
 
 struct attr_set {
+       unsigned        flags;
+#define        PC_CONFIGURED   (0x1)
+#define        PC_REFERENCED   (0x2)
        AttributeName*  attrs;          /* specifies the set */
        int             count;          /* number of attributes */
        int*            ID_array;       /* array of indices of supersets of 'attrs' */
@@ -124,7 +127,7 @@ typedef struct cache_manager_s {
 #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;
 
@@ -730,6 +733,7 @@ static void cache_replacement(query_manager* qm, struct berval *result)
                Debug ( LDAP_DEBUG_ANY,
                        "Cache replacement invoked without "
                        "any query in LRU list\n", 0, 0, 0 );
+               ldap_pvt_thread_mutex_unlock(&qm->lru_mutex);
                return;
        }
 
@@ -1082,7 +1086,7 @@ cache_entries(
 }
 
 static int
-proxy_cache_response(
+pcache_response(
        Operation       *op,
        SlapReply       *rs )
 {
@@ -1117,13 +1121,16 @@ 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 );
                }
-               rs->sr_attrs = si->query.save_attrs;
-               op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
-               op->ors_attrs = si->query.save_attrs;
-               si->query.save_attrs = NULL;
+
+               if ( si->query.save_attrs != NULL ) {
+                       rs->sr_attrs = si->query.save_attrs;
+                       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 ) {
                if ( si->count && cache_entries( op, rs, &uuid ) == 0 ) {
@@ -1205,8 +1212,44 @@ add_filter_attrs(
        }
 }
 
+/* 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
+pcache_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(
+pcache_op_search(
        Operation       *op,
        SlapReply       *rs )
 {
@@ -1241,6 +1284,9 @@ proxy_cache_search(
        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);
 
@@ -1331,7 +1377,7 @@ proxy_cache_search(
                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;
@@ -1423,7 +1469,7 @@ consistency_check(
        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};
@@ -1431,7 +1477,7 @@ consistency_check(
        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;
@@ -1671,21 +1717,22 @@ pc_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
 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;
+       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 = 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->num_entries_limit, cm->cc_period );
                        bv.bv_val = c->msg;
@@ -1695,7 +1742,7 @@ pc_cf_gen( ConfigArgs *c )
                        for (i=0; i<cm->numattrsets; i++) {
                                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 */
                                for ( attr_name = qm->attr_sets[i].attrs;
@@ -1716,7 +1763,7 @@ pc_cf_gen( ConfigArgs *c )
                        break;
                case PC_TEMP:
                        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].ttl );
                                bv.bv_len += qm->templates[i].querystr.bv_len + 2;
@@ -1754,48 +1801,98 @@ pc_cf_gen( ConfigArgs *c )
 
        switch( c->type ) {
        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 ) {
-                       sprintf( c->msg, "numattrsets must be <= %d", MAX_ATTR_SETS );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
+                       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 );
                        return( 1 );
                }
-               cm->db.bd_info = backend_info( c->argv[1] );
-               if ( !cm->db.bd_info ) {
-                       sprintf( c->msg, "unknown backend type" );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
+
+               if ( !backend_db_init( c->argv[1], &cm->db )) {
+                       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->db.bd_info->bi_db_init( &cm->db ) ) {
-                       sprintf( c->msg, "backend %s init failed", c->argv[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 );
                        return( 1 );
                }
 
-               /* This type is in use, needs to be opened */
-               cm->db.bd_info->bi_nDB++;
-
-               cm->max_entries = atoi( c->argv[2] );
+               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 );
+               }
+               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 );
+               }
 
-               cm->num_entries_limit = atoi( c->argv[4] );
-               cm->cc_period = atoi( c->argv[5] );
+               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,
-                               "Total # of attribute sets to be cached = %d\n",
+                               "Total # of attribute sets to be cached = %d.\n",
                                cm->numattrsets, 0, 0 );
-               qm->attr_sets = ( struct attr_set * )ch_malloc( cm->numattrsets *
-                                               sizeof( struct attr_set ));
-               for ( i = 0; i < cm->numattrsets; i++ ) {
-                       qm->attr_sets[i].attrs = NULL;
-               }
+               qm->attr_sets = ( struct attr_set * )ch_calloc( cm->numattrsets,
+                                               sizeof( struct attr_set ) );
                break;
        case PC_ATTR:
-               num = atoi( c->argv[1] );
-               if (num >= cm->numattrsets) {
-                       sprintf( c->msg, "attrset index out of bounds" );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
+               if ( cm->numattrsets == 0 ) {
+                       snprintf( c->msg, sizeof( c->msg ), "\"proxycache\" directive not provided yet" );
+                       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;
                }
-               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].attrs = (AttributeName*)ch_malloc(
                                                (c->argc-1) * sizeof( AttributeName ));
@@ -1804,9 +1901,10 @@ pc_cf_gen( ConfigArgs *c )
                                ber_str2bv( c->argv[i], 0, 1, &attr_name->an_name);
                                attr_name->an_desc = NULL;
                                if ( slap_bv2ad( &attr_name->an_name,
-                                               &attr_name->an_desc, &text )) {
+                                               &attr_name->an_desc, &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 );
                                        qm->attr_sets[num].attrs = NULL;
                                        qm->attr_sets[num].count = 0;
@@ -1820,9 +1918,22 @@ pc_cf_gen( ConfigArgs *c )
                }
                break;
        case PC_TEMP:
-               if (( i = atoi( c->argv[2] )) >= cm->numattrsets ) {
-                       sprintf( c->msg, "template index invalid" );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
+               if ( cm->numattrsets == 0 ) {
+                       snprintf( c->msg, sizeof( c->msg ), "\"proxycache\" directive not provided yet" );
+                       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;
                }
                num = cm->numtemplates;
@@ -1833,7 +1944,14 @@ pc_cf_gen( ConfigArgs *c )
                temp = qm->templates + num;
                ldap_pvt_thread_rdwr_init( &temp->t_rwlock );
                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;
 
                ber_str2bv( c->argv[1], 0, 1, &temp->querystr );
@@ -1841,6 +1959,7 @@ pc_cf_gen( ConfigArgs *c )
                Debug( LDAP_DEBUG_TRACE, "  query template: %s\n",
                                temp->querystr.bv_val, 0, 0 );
                temp->attr_set_index = i;
+               qm->attr_sets[i].flags |= PC_REFERENCED;
                Debug( LDAP_DEBUG_TRACE, "  attributes: \n", 0, 0, 0 );
                if ( ( attrarray = qm->attr_sets[i].attrs ) != NULL ) {
                        for ( i=0; attrarray[i].an_name.bv_val; i++ )
@@ -1859,8 +1978,8 @@ pc_cf_gen( ConfigArgs *c )
                        cm->response_cb = PCACHE_RESPONSE_CB_TAIL;
 
                } else {
-                       sprintf( c->msg, "unknown specifier" );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
+                       snprintf( c->msg, sizeof( c->msg ), "unknown specifier" );
+                       Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                        return 1;
                }
                break;
@@ -1869,7 +1988,7 @@ pc_cf_gen( ConfigArgs *c )
 }
 
 static int
-proxy_cache_config(
+pcache_db_config(
        BackendDB       *be,
        const char      *fname,
        int             lineno,
@@ -1888,7 +2007,7 @@ proxy_cache_config(
 }
 
 static int
-proxy_cache_init(
+pcache_db_init(
        BackendDB *be
 )
 {
@@ -1933,13 +2052,42 @@ proxy_cache_init(
 }
 
 static int
-proxy_cache_open(
+pcache_db_open(
        BackendDB *be
 )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        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... */
        cm->db.be_def_limit = be->be_def_limit;
@@ -1961,7 +2109,7 @@ proxy_cache_open(
                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",
@@ -1975,7 +2123,7 @@ proxy_cache_open(
 }
 
 static int
-proxy_cache_close(
+pcache_db_close(
        BackendDB *be
 )
 {
@@ -2017,7 +2165,7 @@ proxy_cache_close(
 }
 
 static int
-proxy_cache_destroy(
+pcache_db_destroy(
        BackendDB *be
 )
 {
@@ -2033,7 +2181,9 @@ proxy_cache_destroy(
        BER_BVZERO( &cm->db.be_rootpw );
        /* 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( &cm->cache_mutex );
@@ -2044,9 +2194,14 @@ proxy_cache_destroy(
        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;
@@ -2056,7 +2211,7 @@ int pcache_init()
                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;
        }
@@ -2067,30 +2222,34 @@ int pcache_init()
        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;
+
+       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