/usr/src/redhat/BUILD/httpd-2.2.3/modules/ldap/util_ldap_cache.h

説明を見る。
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APU_LDAP_CACHE_H
00018 #define APU_LDAP_CACHE_H
00019 
00025 /* this whole thing disappears if LDAP is not enabled */
00026 #if APR_HAS_LDAP
00027 
00028 
00029 /*
00030  * LDAP Cache Manager
00031  */
00032 
00033 #include "util_ldap.h"
00034 
00035 typedef struct util_cache_node_t {
00036     void *payload;              /* Pointer to the payload */
00037     apr_time_t add_time;        /* Time node was added to cache */
00038     struct util_cache_node_t *next;
00039 } util_cache_node_t;
00040 
00041 typedef struct util_ald_cache util_ald_cache_t;
00042 
00043 struct util_ald_cache {
00044     unsigned long size;                 /* Size of cache array */
00045     unsigned long maxentries;           /* Maximum number of cache entries */
00046     unsigned long numentries;           /* Current number of cache entries */
00047     unsigned long fullmark;             /* Used to keep track of when cache becomes 3/4 full */
00048     apr_time_t marktime;                /* Time that the cache became 3/4 full */
00049     unsigned long (*hash)(void *);      /* Func to hash the payload */
00050     int (*compare)(void *, void *);     /* Func to compare two payloads */
00051     void * (*copy)(util_ald_cache_t *cache, void *); /* Func to alloc mem and copy payload to new mem */
00052     void (*free)(util_ald_cache_t *cache, void *); /* Func to free mem used by the payload */
00053     void (*display)(request_rec *r, util_ald_cache_t *cache, void *); /* Func to display the payload contents */
00054     util_cache_node_t **nodes;
00055 
00056     unsigned long numpurges;    /* No. of times the cache has been purged */
00057     double avg_purgetime;       /* Average time to purge the cache */
00058     apr_time_t last_purge;      /* Time of the last purge */
00059     unsigned long npurged;      /* Number of elements purged in last purge. This is not
00060                                    obvious: it won't be 3/4 the size of the cache if 
00061                                    there were a lot of expired entries. */
00062 
00063     unsigned long fetches;      /* Number of fetches */
00064     unsigned long hits;         /* Number of cache hits */
00065     unsigned long inserts;      /* Number of inserts */
00066     unsigned long removes;      /* Number of removes */
00067 
00068 #if APR_HAS_SHARED_MEMORY
00069     apr_shm_t *shm_addr;
00070     apr_rmm_t *rmm_addr;
00071 #endif
00072 
00073 };
00074 
00075 #ifndef WIN32
00076 #define ALD_MM_FILE_MODE ( S_IRUSR|S_IWUSR )
00077 #else
00078 #define ALD_MM_FILE_MODE ( _S_IREAD|_S_IWRITE )
00079 #endif
00080 
00081 
00082 /*
00083  * LDAP Cache
00084  */
00085 
00086 /*
00087  * Maintain a cache of LDAP URLs that the server handles. Each node in
00088  * the cache contains the search cache for that URL, and a compare cache
00089  * for the URL. The compare cash is populated when doing require group
00090  * compares.
00091  */
00092 typedef struct util_url_node_t {
00093     const char *url;
00094     util_ald_cache_t *search_cache;
00095     util_ald_cache_t *compare_cache;
00096     util_ald_cache_t *dn_compare_cache;
00097 } util_url_node_t;
00098 
00099 /*
00100  * We cache every successful search and bind operation, using the username 
00101  * as the key. Each node in the cache contains the returned DN, plus the 
00102  * password used to bind.
00103  */
00104 typedef struct util_search_node_t {
00105     const char *username;               /* Cache key */
00106     const char *dn;                     /* DN returned from search */
00107     const char *bindpw;                 /* The most recently used bind password; 
00108                                            NULL if the bind failed */
00109     apr_time_t lastbind;                /* Time of last successful bind */
00110     const char **vals;                  /* Values of queried attributes */
00111     int        numvals;         /* Number of queried attributes */
00112 } util_search_node_t;
00113 
00114 /*
00115  * We cache every successful compare operation, using the DN, attrib, and
00116  * value as the key. 
00117  */
00118 typedef struct util_compare_node_t {
00119     const char *dn;                     /* DN, attrib and value combine to be the key */
00120     const char *attrib;                 
00121     const char *value;
00122     apr_time_t lastcompare;
00123     int result;
00124 } util_compare_node_t;
00125 
00126 /*
00127  * We cache every successful compare dn operation, using the dn in the require
00128  * statement and the dn fetched based on the client-provided username.
00129  */
00130 typedef struct util_dn_compare_node_t {
00131     const char *reqdn;          /* The DN in the require dn statement */
00132     const char *dn;                     /* The DN found in the search */
00133 } util_dn_compare_node_t;
00134 
00135 
00136 /*
00137  * Function prototypes for LDAP cache
00138  */
00139 
00140 /* util_ldap_cache.c */
00141 unsigned long util_ldap_url_node_hash(void *n);
00142 int util_ldap_url_node_compare(void *a, void *b);
00143 void *util_ldap_url_node_copy(util_ald_cache_t *cache, void *c);
00144 void util_ldap_url_node_free(util_ald_cache_t *cache, void *n);
00145 void util_ldap_url_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00146 
00147 unsigned long util_ldap_search_node_hash(void *n);
00148 int util_ldap_search_node_compare(void *a, void *b);
00149 void *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c);
00150 void util_ldap_search_node_free(util_ald_cache_t *cache, void *n);
00151 void util_ldap_search_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00152 
00153 unsigned long util_ldap_compare_node_hash(void *n);
00154 int util_ldap_compare_node_compare(void *a, void *b);
00155 void *util_ldap_compare_node_copy(util_ald_cache_t *cache, void *c);
00156 void util_ldap_compare_node_free(util_ald_cache_t *cache, void *n);
00157 void util_ldap_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00158 
00159 unsigned long util_ldap_dn_compare_node_hash(void *n);
00160 int util_ldap_dn_compare_node_compare(void *a, void *b);
00161 void *util_ldap_dn_compare_node_copy(util_ald_cache_t *cache, void *c);
00162 void util_ldap_dn_compare_node_free(util_ald_cache_t *cache, void *n);
00163 void util_ldap_dn_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00164 
00165 
00166 /* util_ldap_cache_mgr.c */
00167 
00168 /* Cache alloc and free function, dealing or not with shm */
00169 void util_ald_free(util_ald_cache_t *cache, const void *ptr);
00170 void *util_ald_alloc(util_ald_cache_t *cache, unsigned long size);
00171 const char *util_ald_strdup(util_ald_cache_t *cache, const char *s);
00172 
00173 /* Cache managing function */
00174 unsigned long util_ald_hash_string(int nstr, ...);
00175 void util_ald_cache_purge(util_ald_cache_t *cache);
00176 util_url_node_t *util_ald_create_caches(util_ldap_state_t *s, const char *url);
00177 util_ald_cache_t *util_ald_create_cache(util_ldap_state_t *st,
00178                                 long cache_size,
00179                                 unsigned long (*hashfunc)(void *), 
00180                                 int (*comparefunc)(void *, void *),
00181                                 void * (*copyfunc)(util_ald_cache_t *cache, void *),
00182                                 void (*freefunc)(util_ald_cache_t *cache, void *),
00183                                 void (*displayfunc)(request_rec *r, util_ald_cache_t *cache, void *));
00184                                 
00185 void util_ald_destroy_cache(util_ald_cache_t *cache);
00186 void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload);
00187 void *util_ald_cache_insert(util_ald_cache_t *cache, void *payload);
00188 void util_ald_cache_remove(util_ald_cache_t *cache, void *payload);
00189 char *util_ald_cache_display_stats(request_rec *r, util_ald_cache_t *cache, char *name, char *id);
00190 
00191 #endif /* APR_HAS_LDAP */
00192 #endif /* APU_LDAP_CACHE_H */

Apacheに対してSun Jul 19 22:05:23 2009に生成されました。  doxygen 1.4.7