]> 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 1e488649e4e0d983be60c3c013a7afaa0296fd52..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;
 
@@ -127,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;
 
@@ -1086,7 +1086,7 @@ cache_entries(
 }
 
 static int
-proxy_cache_response(
+pcache_response(
        Operation       *op,
        SlapReply       *rs )
 {
@@ -1218,7 +1218,7 @@ add_filter_attrs(
  * 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 )
 {
@@ -1249,7 +1249,7 @@ proxy_cache_chk_controls(
 }
 
 static int
-proxy_cache_search(
+pcache_op_search(
        Operation       *op,
        SlapReply       *rs )
 {
@@ -1377,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;
@@ -1732,7 +1732,7 @@ pc_cf_gen( ConfigArgs *c )
                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;
@@ -1865,7 +1865,7 @@ pc_cf_gen( ConfigArgs *c )
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                        return( 1 );
                }
-               cm->cc_period = t;
+               cm->cc_period = (time_t)t;
                Debug( LDAP_DEBUG_TRACE,
                                "Total # of attribute sets to be cached = %d.\n",
                                cm->numattrsets, 0, 0 );
@@ -1950,7 +1950,7 @@ pc_cf_gen( ConfigArgs *c )
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                        return( 1 );
                }
-               temp->ttl = (long)t;
+               temp->ttl = (time_t)t;
 
                temp->no_of_queries = 0;
 
@@ -1988,7 +1988,7 @@ pc_cf_gen( ConfigArgs *c )
 }
 
 static int
-proxy_cache_config(
+pcache_db_config(
        BackendDB       *be,
        const char      *fname,
        int             lineno,
@@ -2007,7 +2007,7 @@ proxy_cache_config(
 }
 
 static int
-proxy_cache_init(
+pcache_db_init(
        BackendDB *be
 )
 {
@@ -2052,7 +2052,7 @@ proxy_cache_init(
 }
 
 static int
-proxy_cache_open(
+pcache_db_open(
        BackendDB *be
 )
 {
@@ -2109,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",
@@ -2123,7 +2123,7 @@ proxy_cache_open(
 }
 
 static int
-proxy_cache_close(
+pcache_db_close(
        BackendDB *be
 )
 {
@@ -2165,7 +2165,7 @@ proxy_cache_close(
 }
 
 static int
-proxy_cache_destroy(
+pcache_db_destroy(
        BackendDB *be
 )
 {
@@ -2194,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;
@@ -2206,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;
        }
@@ -2217,32 +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;
 
-       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