]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/pcache.c
fix wrong response tags (ITS4182; consequence of fixing ITS#4173)
[openldap] / servers / slapd / overlays / pcache.c
index 78549fbe26a80b00badb47ff69c219aeed8ea32d..b34ab149ad97213a2a029a498dc1e5e592530452 100644 (file)
@@ -1205,6 +1205,42 @@ 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
+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,
@@ -1241,6 +1277,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);
 
@@ -1423,7 +1462,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 +1470,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;
@@ -1760,21 +1799,11 @@ pc_cf_gen( ConfigArgs *c )
                        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] );
@@ -2080,6 +2109,8 @@ int pcache_init()
        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 );