/* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * * Copyright 2003-2022 The OpenLDAP Foundation. * Portions Copyright 2003 IBM Corporation. * Portions Copyright 2003-2009 Symas Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in the file LICENSE in the * top-level directory of the distribution or, alternatively, at * . */ /* ACKNOWLEDGEMENTS: * This work was initially developed by Apurva Kumar for inclusion * in OpenLDAP Software and subsequently rewritten by Howard Chu. */ #include "portable.h" #ifdef SLAPD_OVER_PROXYCACHE #include #include #include #include "slap.h" #include "lutil.h" #include "ldap_rq.h" #include "ldap_avl.h" #include "../back-monitor/back-monitor.h" #include "slap-config.h" /* * Control that allows to access the private DB * instead of the public one */ #define PCACHE_CONTROL_PRIVDB "1.3.6.1.4.1.4203.666.11.9.5.1" /* * Extended Operation that allows to remove a query from the cache */ #define PCACHE_EXOP_QUERY_DELETE "1.3.6.1.4.1.4203.666.11.9.6.1" /* * Monitoring */ #define PCACHE_MONITOR /* query cache structs */ /* query */ typedef struct Query_s { Filter* filter; /* Search Filter */ struct berval base; /* Search Base */ int scope; /* Search scope */ } Query; struct query_template_s; typedef struct Qbase_s { TAvlnode *scopes[4]; /* threaded AVL trees of cached queries */ struct berval base; int queries; } Qbase; /* struct representing a cached query */ typedef struct cached_query_s { Filter *filter; Filter *first; Qbase *qbase; int scope; struct berval q_uuid; /* query identifier */ int q_sizelimit; struct query_template_s *qtemp; /* template of the query */ time_t expiry_time; /* time till the query is considered invalid */ time_t refresh_time; /* time till the query is refreshed */ time_t bindref_time; /* time till the bind is refreshed */ int bind_refcnt; /* number of bind operation referencing this query */ unsigned long answerable_cnt; /* how many times it was answerable */ int refcnt; /* references since last refresh */ int in_lru; /* query is in LRU list */ ldap_pvt_thread_mutex_t answerable_cnt_mutex; struct cached_query_s *next; /* next query in the template */ struct cached_query_s *prev; /* previous query in the template */ struct cached_query_s *lru_up; /* previous query in the LRU list */ struct cached_query_s *lru_down; /* next query in the LRU list */ ldap_pvt_thread_rdwr_t rwlock; } CachedQuery; /* * URL representation: * * ldap:///????x-uuid=,x-template=