View | Details | Raw Unified | Return to bug 18756
Collapse All | Expand All

(-)include/util_ldap.h (-7 / +21 lines)
Lines 75-80 Link Here
75
#include "http_protocol.h"
75
#include "http_protocol.h"
76
#include "http_request.h"
76
#include "http_request.h"
77
77
78
#if APR_HAS_SHARED_MEMORY
79
#include "apr_rmm.h"
80
#include "apr_shm.h"
81
#endif
78
82
79
/* Create a set of LDAP_DECLARE(type), LDLDAP_DECLARE(type) and 
83
/* Create a set of LDAP_DECLARE(type), LDLDAP_DECLARE(type) and 
80
 * LDAP_DECLARE_DATA with appropriate export and import tags for the platform
84
 * LDAP_DECLARE_DATA with appropriate export and import tags for the platform
Lines 97-103 Link Here
97
#define LDAP_DECLARE_DATA             __declspec(dllimport)
101
#define LDAP_DECLARE_DATA             __declspec(dllimport)
98
#endif
102
#endif
99
103
100
101
/*
104
/*
102
 * LDAP Connections
105
 * LDAP Connections
103
 */
106
 */
Lines 138-146 Link Here
138
    apr_pool_t *pool;           /* pool from which this state is allocated */
141
    apr_pool_t *pool;           /* pool from which this state is allocated */
139
#if APR_HAS_THREADS
142
#if APR_HAS_THREADS
140
    apr_thread_mutex_t *mutex;          /* mutex lock for the connection list */
143
    apr_thread_mutex_t *mutex;          /* mutex lock for the connection list */
144
    apr_thread_rwlock_t *util_ldap_cache_lock;
141
#endif
145
#endif
142
146
143
    apr_size_t cache_bytes;     /* Size (in bytes) of shared memory cache */
147
    apr_size_t cache_bytes;     /* Size (in bytes) of shared memory cache */
148
    char *cache_file;		/* filename for shm */
144
    long search_cache_ttl;      /* TTL for search cache */
149
    long search_cache_ttl;      /* TTL for search cache */
145
    long search_cache_size;     /* Size (in entries) of search cache */
150
    long search_cache_size;     /* Size (in entries) of search cache */
146
    long compare_cache_ttl;     /* TTL for compare cache */
151
    long compare_cache_ttl;     /* TTL for compare cache */
Lines 150-155 Link Here
150
    char *cert_auth_file; 
155
    char *cert_auth_file; 
151
    int   cert_file_type;
156
    int   cert_file_type;
152
    int   ssl_support;
157
    int   ssl_support;
158
159
#if APR_HAS_SHARED_MEMORY
160
    apr_shm_t *cache_shm;
161
    apr_rmm_t *cache_rmm;
162
#endif
163
164
    /* cache ald */
165
    void *util_ldap_cache;
166
153
} util_ldap_state_t;
167
} util_ldap_state_t;
154
168
155
169
Lines 286-306 Link Here
286
 * @param reqsize The size of the shared memory segement to request. A size
300
 * @param reqsize The size of the shared memory segement to request. A size
287
 *                of zero requests the max size possible from
301
 *                of zero requests the max size possible from
288
 *                apr_shmem_init()
302
 *                apr_shmem_init()
289
 * @deffunc void util_ldap_cache_init(apr_pool_t *p)
303
 * @deffunc void util_ldap_cache_init(apr_pool_t *p, util_ldap_state_t *st)
290
 * @return The status code returned is the status code of the
304
 * @return The status code returned is the status code of the
291
 *         apr_smmem_init() call. Regardless of the status, the cache
305
 *         apr_smmem_init() call. Regardless of the status, the cache
292
 *         will be set up at least for in-process or in-thread operation.
306
 *         will be set up at least for in-process or in-thread operation.
293
 */
307
 */
294
apr_status_t util_ldap_cache_init(apr_pool_t *pool, apr_size_t reqsize);
308
apr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st);
295
309
296
/**
310
/**
297
 * Display formatted stats for cache
311
 * Display formatted stats for cache
298
 * @param The pool to allocate the returned string from
312
 * @param The pool to allocate the returned string from
299
 * @tip This function returns a string allocated from the provided pool that describes
313
 * @tip This function returns a string allocated from the provided pool that describes
300
 *      various stats about the cache.
314
 *      various stats about the cache.
301
 * @deffunc char *util_ald_cache_display(apr_pool_t *pool)
315
 * @deffunc char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st)
302
 */
316
 */
303
char *util_ald_cache_display(apr_pool_t *pool);
317
char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st);
304
318
305
319
306
/* from apr_ldap_cache_mgr.c */
320
/* from apr_ldap_cache_mgr.c */
Lines 310-318 Link Here
310
 * @param The pool to allocate the returned string from
324
 * @param The pool to allocate the returned string from
311
 * @tip This function returns a string allocated from the provided pool that describes
325
 * @tip This function returns a string allocated from the provided pool that describes
312
 *      various stats about the cache.
326
 *      various stats about the cache.
313
 * @deffunc char *util_ald_cache_display(apr_pool_t *pool)
327
 * @deffunc char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st)
314
 */
328
 */
315
char *util_ald_cache_display(apr_pool_t *pool);
329
char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st);
316
330
317
#endif /* APU_HAS_LDAP */
331
#endif /* APU_HAS_LDAP */
318
#endif /* UTIL_LDAP_H */
332
#endif /* UTIL_LDAP_H */
(-)modules/experimental/util_ldap.c (-27 / +59 lines)
Lines 141-146 Link Here
141
 */
141
 */
142
int util_ldap_handler(request_rec *r)
142
int util_ldap_handler(request_rec *r)
143
{
143
{
144
    util_ldap_state_t *st = (util_ldap_state_t *)ap_get_module_config(r->server->module_config, &ldap_module);
144
145
145
    r->allowed |= (1 << M_GET);
146
    r->allowed |= (1 << M_GET);
146
    if (r->method_number != M_GET)
147
    if (r->method_number != M_GET)
Lines 171-177 Link Here
171
             "</tr>\n", r
172
             "</tr>\n", r
172
            );
173
            );
173
174
174
    ap_rputs(util_ald_cache_display(r->pool), r);
175
    ap_rputs(util_ald_cache_display(r->pool, st), r);
175
176
176
    ap_rputs("</table>\n</p>\n", r);
177
    ap_rputs("</table>\n</p>\n", r);
177
178
Lines 506-514 Link Here
506
    LDAPMessage *res, *entry;
507
    LDAPMessage *res, *entry;
507
    char *searchdn;
508
    char *searchdn;
508
509
509
    util_ldap_state_t *st = 
510
    util_ldap_state_t *st =  (util_ldap_state_t *)ap_get_module_config(r->server->module_config, &ldap_module);
510
        (util_ldap_state_t *)ap_get_module_config(r->server->module_config,
511
        &ldap_module);
512
511
513
    /* read lock this function */
512
    /* read lock this function */
514
    LDAP_CACHE_LOCK_CREATE(st->pool);
513
    LDAP_CACHE_LOCK_CREATE(st->pool);
Lines 517-523 Link Here
517
    LDAP_CACHE_WRLOCK();
516
    LDAP_CACHE_WRLOCK();
518
517
519
    curnode.url = url;
518
    curnode.url = url;
520
    curl = util_ald_cache_fetch(util_ldap_cache, &curnode);
519
    curl = util_ald_cache_fetch(st->util_ldap_cache, &curnode);
521
    if (curl == NULL) {
520
    if (curl == NULL) {
522
        curl = util_ald_create_caches(st, url);
521
        curl = util_ald_create_caches(st, url);
523
    }
522
    }
Lines 637-643 Link Here
637
    /* get cache entry (or create one) */
636
    /* get cache entry (or create one) */
638
    LDAP_CACHE_WRLOCK();
637
    LDAP_CACHE_WRLOCK();
639
    curnode.url = url;
638
    curnode.url = url;
640
    curl = util_ald_cache_fetch(util_ldap_cache, &curnode);
639
    curl = util_ald_cache_fetch(st->util_ldap_cache, &curnode);
641
    if (curl == NULL) {
640
    if (curl == NULL) {
642
        curl = util_ald_create_caches(st, url);
641
        curl = util_ald_create_caches(st, url);
643
    }
642
    }
Lines 760-766 Link Here
760
    /* Get the cache node for this url */
759
    /* Get the cache node for this url */
761
    LDAP_CACHE_WRLOCK();
760
    LDAP_CACHE_WRLOCK();
762
    curnode.url = url;
761
    curnode.url = url;
763
    curl = (util_url_node_t *)util_ald_cache_fetch(util_ldap_cache, &curnode);
762
    curl = (util_url_node_t *)util_ald_cache_fetch(st->util_ldap_cache, &curnode);
764
    if (curl == NULL) {
763
    if (curl == NULL) {
765
        curl = util_ald_create_caches(st, url);
764
        curl = util_ald_create_caches(st, url);
766
    }
765
    }
Lines 962-967 Link Here
962
    return NULL;
961
    return NULL;
963
}
962
}
964
963
964
static const char *util_ldap_set_cache_file(cmd_parms *cmd, void *dummy, const char *file)
965
{
966
    util_ldap_state_t *st = 
967
        (util_ldap_state_t *)ap_get_module_config(cmd->server->module_config, 
968
						  &ldap_module);
969
970
    if (file)    
971
    	st->cache_file = ap_server_root_relative(st->pool, file);
972
    else
973
        st->cache_file = NULL;
974
975
    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, cmd->server, 
976
    		      "LDAP cache: Setting shared memory cache file to %s bytes.", 
977
                      st->cache_file);
978
979
    return NULL;
980
}
981
965
static const char *util_ldap_set_cache_ttl(cmd_parms *cmd, void *dummy, const char *ttl)
982
static const char *util_ldap_set_cache_ttl(cmd_parms *cmd, void *dummy, const char *ttl)
966
{
983
{
967
    util_ldap_state_t *st = 
984
    util_ldap_state_t *st = 
Lines 1091-1112 Link Here
1091
    return st;
1108
    return st;
1092
}
1109
}
1093
1110
1094
static void util_ldap_init_module(apr_pool_t *pool, server_rec *s)
1095
{
1096
    util_ldap_state_t *st = 
1097
        (util_ldap_state_t *)ap_get_module_config(s->module_config, 
1098
						  &ldap_module);
1099
1100
    apr_status_t result = util_ldap_cache_init(pool, st->cache_bytes);
1101
    char buf[MAX_STRING_LEN];
1102
1103
    apr_strerror(result, buf, sizeof(buf));
1104
    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, result, s, 
1105
                      "[%d] ldap cache init: %s", 
1106
                      getpid(), buf);
1107
}
1108
1109
1110
static apr_status_t util_ldap_cleanup_module(void *data)
1111
static apr_status_t util_ldap_cleanup_module(void *data)
1111
{
1112
{
1112
    server_rec *s = data;
1113
    server_rec *s = data;
Lines 1128-1138 Link Here
1128
                                 apr_pool_t *ptemp, server_rec *s)
1129
                                 apr_pool_t *ptemp, server_rec *s)
1129
{
1130
{
1130
    int rc = LDAP_SUCCESS;
1131
    int rc = LDAP_SUCCESS;
1132
    apr_status_t result;
1133
    char buf[MAX_STRING_LEN];
1131
1134
1132
    util_ldap_state_t *st = (util_ldap_state_t *)ap_get_module_config(
1135
    server_rec *s_vhost;
1133
                                                s->module_config, 
1136
    util_ldap_state_t *st_vhost;
1134
                                                &ldap_module);
1137
    
1138
    util_ldap_state_t *st = (util_ldap_state_t *)ap_get_module_config(s->module_config, &ldap_module);
1135
1139
1140
    /* initializing cache if file is here and we already don't have shm addr*/
1141
    if (st->cache_file && !st->cache_shm) {
1142
	    result = util_ldap_cache_init(p, st);
1143
	    apr_strerror(result, buf, sizeof(buf));
1144
	    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, result, s, "LDAP cache init: %s",buf);
1145
1146
1147
	/* merge config in all vhost */
1148
	s_vhost = s->next;
1149
	while (s_vhost) {
1150
		ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, result, s, 
1151
				"LDAP merging Shared Cache conf: shm=0x%x rmm=0x%x for VHOST: %s",
1152
				 st->cache_shm, st->cache_rmm, s_vhost->server_hostname);
1153
				 
1154
		st_vhost = (util_ldap_state_t *)ap_get_module_config(s_vhost->module_config, &ldap_module);	
1155
		st_vhost->cache_shm = st->cache_shm;
1156
		st_vhost->cache_rmm = st->cache_rmm;
1157
		st_vhost->cache_file = st->cache_file;
1158
		s_vhost = s_vhost->next;
1159
	}
1160
1161
    } else {
1162
	    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0 , s, "LDAP cache: Unable to init Shared Cache: no file");
1163
    }
1164
  
1136
        /* log the LDAP SDK used 
1165
        /* log the LDAP SDK used 
1137
        */
1166
        */
1138
    #if APR_HAS_NETSCAPE_LDAPSDK 
1167
    #if APR_HAS_NETSCAPE_LDAPSDK 
Lines 1297-1302 Link Here
1297
                  "Sets the size of the shared memory cache in bytes. "
1326
                  "Sets the size of the shared memory cache in bytes. "
1298
                  "Zero means disable the shared memory cache. Defaults to 100KB."),
1327
                  "Zero means disable the shared memory cache. Defaults to 100KB."),
1299
1328
1329
    AP_INIT_TAKE1("LDAPSharedCacheFile", util_ldap_set_cache_file, NULL, RSRC_CONF,
1330
                  "Sets the file of the shared memory cache."
1331
                  "Nothing means disable the shared memory cache."),
1332
1300
    AP_INIT_TAKE1("LDAPCacheEntries", util_ldap_set_cache_entries, NULL, RSRC_CONF,
1333
    AP_INIT_TAKE1("LDAPCacheEntries", util_ldap_set_cache_entries, NULL, RSRC_CONF,
1301
                  "Sets the maximum number of entries that are possible in the LDAP "
1334
                  "Sets the maximum number of entries that are possible in the LDAP "
1302
                  "search cache. "
1335
                  "search cache. "
Lines 1331-1337 Link Here
1331
static void util_ldap_register_hooks(apr_pool_t *p)
1364
static void util_ldap_register_hooks(apr_pool_t *p)
1332
{
1365
{
1333
    ap_hook_post_config(util_ldap_post_config,NULL,NULL,APR_HOOK_MIDDLE);
1366
    ap_hook_post_config(util_ldap_post_config,NULL,NULL,APR_HOOK_MIDDLE);
1334
    ap_hook_child_init(util_ldap_init_module, NULL, NULL, APR_HOOK_MIDDLE);
1335
    ap_hook_handler(util_ldap_handler, NULL, NULL, APR_HOOK_MIDDLE);
1367
    ap_hook_handler(util_ldap_handler, NULL, NULL, APR_HOOK_MIDDLE);
1336
}
1368
}
1337
1369
(-)modules/experimental/util_ldap_cache.c (-55 / +61 lines)
Lines 85-98 Link Here
85
    return(strcmp(na->url, nb->url) == 0);
85
    return(strcmp(na->url, nb->url) == 0);
86
}
86
}
87
87
88
void *util_ldap_url_node_copy(void *c)
88
void *util_ldap_url_node_copy(util_ald_cache_t *cache, void *c)
89
{
89
{
90
    util_url_node_t *n = (util_url_node_t *)c;
90
    util_url_node_t *n = (util_url_node_t *)c;
91
    util_url_node_t *node = (util_url_node_t *)util_ald_alloc(sizeof(util_url_node_t));
91
    util_url_node_t *node = (util_url_node_t *)util_ald_alloc(cache->rmm_addr, sizeof(util_url_node_t));
92
92
93
    if (node) {
93
    if (node) {
94
        if (!(node->url = util_ald_strdup(n->url))) {
94
        if (!(node->url = util_ald_strdup(cache->rmm_addr, n->url))) {
95
            util_ald_free(node->url);
95
            util_ald_free(cache->rmm_addr, node->url);
96
            return NULL;
96
            return NULL;
97
        }
97
        }
98
        node->search_cache = n->search_cache;
98
        node->search_cache = n->search_cache;
Lines 105-119 Link Here
105
    }
105
    }
106
}
106
}
107
107
108
void util_ldap_url_node_free(void *n)
108
void util_ldap_url_node_free(util_ald_cache_t *cache, void *n)
109
{
109
{
110
    util_url_node_t *node = (util_url_node_t *)n;
110
    util_url_node_t *node = (util_url_node_t *)n;
111
111
112
    util_ald_free(node->url);
112
    util_ald_free(cache->rmm_addr, node->url);
113
    util_ald_destroy_cache(node->search_cache);
113
    util_ald_destroy_cache(node->search_cache);
114
    util_ald_destroy_cache(node->compare_cache);
114
    util_ald_destroy_cache(node->compare_cache);
115
    util_ald_destroy_cache(node->dn_compare_cache);
115
    util_ald_destroy_cache(node->dn_compare_cache);
116
    util_ald_free(node);
116
    util_ald_free(cache->rmm_addr, node);
117
}
117
}
118
118
119
/* ------------------------------------------------------------------ */
119
/* ------------------------------------------------------------------ */
Lines 131-140 Link Here
131
		  ((util_search_node_t *)b)->username) == 0);
131
		  ((util_search_node_t *)b)->username) == 0);
132
}
132
}
133
133
134
void *util_ldap_search_node_copy(void *c)
134
void *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c)
135
{
135
{
136
    util_search_node_t *node = (util_search_node_t *)c;
136
    util_search_node_t *node = (util_search_node_t *)c;
137
    util_search_node_t *newnode = util_ald_alloc(sizeof(util_search_node_t));
137
    util_search_node_t *newnode = util_ald_alloc(cache->rmm_addr, sizeof(util_search_node_t));
138
138
139
    /* safety check */
139
    /* safety check */
140
    if (newnode) {
140
    if (newnode) {
Lines 144-156 Link Here
144
            int k = 0;
144
            int k = 0;
145
            int i = 0;
145
            int i = 0;
146
            while (node->vals[k++]);
146
            while (node->vals[k++]);
147
            if (!(newnode->vals = util_ald_alloc(sizeof(char *) * (k+1)))) {
147
            if (!(newnode->vals = util_ald_alloc(cache->rmm_addr, sizeof(char *) * (k+1)))) {
148
                util_ldap_search_node_free(newnode);
148
                util_ldap_search_node_free(cache, newnode);
149
                return NULL;
149
                return NULL;
150
            }
150
            }
151
            while (node->vals[i]) {
151
            while (node->vals[i]) {
152
                if (!(newnode->vals[i] = util_ald_strdup(node->vals[i]))) {
152
                if (!(newnode->vals[i] = util_ald_strdup(cache->rmm_addr, node->vals[i]))) {
153
                    util_ldap_search_node_free(newnode);
153
                    util_ldap_search_node_free(cache, newnode);
154
                    return NULL;
154
                    return NULL;
155
                }
155
                }
156
                i++;
156
                i++;
Lines 159-168 Link Here
159
        else {
159
        else {
160
            newnode->vals = NULL;
160
            newnode->vals = NULL;
161
        }
161
        }
162
        if (!(newnode->username = util_ald_strdup(node->username)) ||
162
        if (!(newnode->username = util_ald_strdup(cache->rmm_addr, node->username)) ||
163
            !(newnode->dn = util_ald_strdup(node->dn)) ||
163
            !(newnode->dn = util_ald_strdup(cache->rmm_addr, node->dn)) ||
164
            !(newnode->bindpw = util_ald_strdup(node->bindpw)) ) {
164
            !(newnode->bindpw = util_ald_strdup(cache->rmm_addr, node->bindpw)) ) {
165
            util_ldap_search_node_free(newnode);
165
            util_ldap_search_node_free(cache, newnode);
166
            return NULL;
166
            return NULL;
167
        }
167
        }
168
        newnode->lastbind = node->lastbind;
168
        newnode->lastbind = node->lastbind;
Lines 171-190 Link Here
171
    return (void *)newnode;
171
    return (void *)newnode;
172
}
172
}
173
173
174
void util_ldap_search_node_free(void *n)
174
void util_ldap_search_node_free(util_ald_cache_t *cache, void *n)
175
{
175
{
176
    int i = 0;
176
    int i = 0;
177
    util_search_node_t *node = (util_search_node_t *)n;
177
    util_search_node_t *node = (util_search_node_t *)n;
178
    if (node->vals) {
178
    if (node->vals) {
179
        while (node->vals[i]) {
179
        while (node->vals[i]) {
180
            util_ald_free(node->vals[i++]);
180
            util_ald_free(cache->rmm_addr, node->vals[i++]);
181
        }
181
        }
182
        util_ald_free(node->vals);
182
        util_ald_free(cache->rmm_addr, node->vals);
183
    }
183
    }
184
    util_ald_free(node->username);
184
    util_ald_free(cache->rmm_addr, node->username);
185
    util_ald_free(node->dn);
185
    util_ald_free(cache->rmm_addr, node->dn);
186
    util_ald_free(node->bindpw);
186
    util_ald_free(cache->rmm_addr, node->bindpw);
187
    util_ald_free(node);
187
    util_ald_free(cache->rmm_addr, node);
188
}
188
}
189
189
190
/* ------------------------------------------------------------------ */
190
/* ------------------------------------------------------------------ */
Lines 204-219 Link Here
204
	    strcmp(na->value, nb->value) == 0);
204
	    strcmp(na->value, nb->value) == 0);
205
}
205
}
206
206
207
void *util_ldap_compare_node_copy(void *c)
207
void *util_ldap_compare_node_copy(util_ald_cache_t *cache, void *c)
208
{
208
{
209
    util_compare_node_t *n = (util_compare_node_t *)c;
209
    util_compare_node_t *n = (util_compare_node_t *)c;
210
    util_compare_node_t *node = (util_compare_node_t *)util_ald_alloc(sizeof(util_compare_node_t));
210
    util_compare_node_t *node = (util_compare_node_t *)util_ald_alloc(cache->rmm_addr, sizeof(util_compare_node_t));
211
211
212
    if (node) {
212
    if (node) {
213
        if (!(node->dn = util_ald_strdup(n->dn)) ||
213
        if (!(node->dn = util_ald_strdup(cache->rmm_addr, n->dn)) ||
214
            !(node->attrib = util_ald_strdup(n->attrib)) ||
214
            !(node->attrib = util_ald_strdup(cache->rmm_addr, n->attrib)) ||
215
            !(node->value = util_ald_strdup(n->value))) {
215
            !(node->value = util_ald_strdup(cache->rmm_addr, n->value))) {
216
            util_ldap_compare_node_free(node);
216
            util_ldap_compare_node_free(cache, node);
217
            return NULL;
217
            return NULL;
218
        }
218
        }
219
        node->lastcompare = n->lastcompare;
219
        node->lastcompare = n->lastcompare;
Lines 225-237 Link Here
225
    }
225
    }
226
}
226
}
227
227
228
void util_ldap_compare_node_free(void *n)
228
void util_ldap_compare_node_free(util_ald_cache_t *cache, void *n)
229
{
229
{
230
    util_compare_node_t *node = (util_compare_node_t *)n;
230
    util_compare_node_t *node = (util_compare_node_t *)n;
231
    util_ald_free(node->dn);
231
    util_ald_free(cache->rmm_addr, node->dn);
232
    util_ald_free(node->attrib);
232
    util_ald_free(cache->rmm_addr, node->attrib);
233
    util_ald_free(node->value);
233
    util_ald_free(cache->rmm_addr, node->value);
234
    util_ald_free(node);
234
    util_ald_free(cache->rmm_addr, node);
235
}
235
}
236
236
237
/* ------------------------------------------------------------------ */
237
/* ------------------------------------------------------------------ */
Lines 247-260 Link Here
247
		   ((util_dn_compare_node_t *)b)->reqdn) == 0);
247
		   ((util_dn_compare_node_t *)b)->reqdn) == 0);
248
}
248
}
249
249
250
void *util_ldap_dn_compare_node_copy(void *c)
250
void *util_ldap_dn_compare_node_copy(util_ald_cache_t *cache, void *c)
251
{
251
{
252
    util_dn_compare_node_t *n = (util_dn_compare_node_t *)c;
252
    util_dn_compare_node_t *n = (util_dn_compare_node_t *)c;
253
    util_dn_compare_node_t *node = (util_dn_compare_node_t *)util_ald_alloc(sizeof(util_dn_compare_node_t));
253
    util_dn_compare_node_t *node = (util_dn_compare_node_t *)util_ald_alloc(cache->rmm_addr, sizeof(util_dn_compare_node_t));
254
    if (node) {
254
    if (node) {
255
        if (!(node->reqdn = util_ald_strdup(n->reqdn)) ||
255
        if (!(node->reqdn = util_ald_strdup(cache->rmm_addr, n->reqdn)) ||
256
            !(node->dn = util_ald_strdup(n->dn))) {
256
            !(node->dn = util_ald_strdup(cache->rmm_addr, n->dn))) {
257
            util_ldap_dn_compare_node_free(node);
257
            util_ldap_dn_compare_node_free(cache, node);
258
            return NULL;
258
            return NULL;
259
        }
259
        }
260
        return node;
260
        return node;
Lines 264-275 Link Here
264
    }
264
    }
265
}
265
}
266
266
267
void util_ldap_dn_compare_node_free(void *n)
267
void util_ldap_dn_compare_node_free(util_ald_cache_t *cache, void *n)
268
{
268
{
269
    util_dn_compare_node_t *node = (util_dn_compare_node_t *)n;
269
    util_dn_compare_node_t *node = (util_dn_compare_node_t *)n;
270
    util_ald_free(node->reqdn);
270
    util_ald_free(cache->rmm_addr, node->reqdn);
271
    util_ald_free(node->dn);
271
    util_ald_free(cache->rmm_addr, node->dn);
272
    util_ald_free(node);
272
    util_ald_free(cache->rmm_addr, node);
273
}
273
}
274
274
275
275
Lines 279-320 Link Here
279
279
280
apr_status_t util_ldap_cache_module_kill(void *data)
280
apr_status_t util_ldap_cache_module_kill(void *data)
281
{
281
{
282
    util_ldap_state_t *st = (util_ldap_state_t *)data;
283
282
#if APR_HAS_SHARED_MEMORY
284
#if APR_HAS_SHARED_MEMORY
283
    if (util_ldap_shm != NULL) {
285
    if (st->cache_shm != NULL) {
284
        apr_status_t result = apr_shm_destroy(util_ldap_shm);
286
        apr_status_t result = apr_shm_destroy(st->cache_shm);
285
        util_ldap_shm = NULL;
287
        st->cache_shm = NULL;
288
	unlink(st->cache_file);
286
        return result;
289
        return result;
287
    }
290
    }
288
#endif
291
#endif
289
    util_ald_destroy_cache(util_ldap_cache);
292
    util_ald_destroy_cache(st->util_ldap_cache);
290
    return APR_SUCCESS;
293
    return APR_SUCCESS;
291
}
294
}
292
295
293
apr_status_t util_ldap_cache_init(apr_pool_t *pool, apr_size_t reqsize)
296
apr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st)
294
{
297
{
295
#if APR_HAS_SHARED_MEMORY
298
#if APR_HAS_SHARED_MEMORY
296
    apr_status_t result;
299
    apr_status_t result;
297
300
298
    result = apr_shm_create(&util_ldap_shm, reqsize, MODLDAP_SHMEM_CACHE, pool);
301
    if (!st->cache_file) {
302
    	return -1;
303
    }
304
305
    result = apr_shm_create(&st->cache_shm, st->cache_bytes, st->cache_file, st->pool);
299
    if (result == EEXIST) {
306
    if (result == EEXIST) {
300
        /*
307
        /*
301
         * The cache could have already been created (i.e. we may be a child process).  See
308
         * The cache could have already been created (i.e. we may be a child process).  See
302
         * if we can attach to the existing shared memory
309
         * if we can attach to the existing shared memory
303
         */
310
         */
304
        result = apr_shm_attach(&util_ldap_shm, MODLDAP_SHMEM_CACHE, pool);
311
        result = apr_shm_attach(&st->cache_shm, st->cache_file, st->pool);
305
    } 
312
    } 
306
    if (result != APR_SUCCESS) {
313
    if (result != APR_SUCCESS) {
307
        return result;
314
        return result;
308
    }
315
    }
309
316
310
    /* This will create a rmm "handler" to get into the shared memory area */
317
    /* This will create a rmm "handler" to get into the shared memory area */
311
    apr_rmm_init(&util_ldap_rmm, NULL,
318
    apr_rmm_init(&st->cache_rmm, NULL, (void *)apr_shm_baseaddr_get(st->cache_shm), st->cache_bytes, st->pool);
312
			(void *)apr_shm_baseaddr_get(util_ldap_shm), reqsize, pool);
313
#endif
319
#endif
314
320
315
    apr_pool_cleanup_register(pool, NULL, util_ldap_cache_module_kill, apr_pool_cleanup_null);
321
    apr_pool_cleanup_register(st->pool, st , util_ldap_cache_module_kill, apr_pool_cleanup_null);
316
322
317
    util_ldap_cache = util_ald_create_cache(50,
323
    st->util_ldap_cache = util_ald_create_cache(st,
318
				     util_ldap_url_node_hash,
324
				     util_ldap_url_node_hash,
319
				     util_ldap_url_node_compare,
325
				     util_ldap_url_node_compare,
320
				     util_ldap_url_node_copy,
326
				     util_ldap_url_node_copy,
(-)modules/experimental/util_ldap_cache.h (-33 / +38 lines)
Lines 77-92 Link Here
77
    struct util_cache_node_t *next;
77
    struct util_cache_node_t *next;
78
} util_cache_node_t;
78
} util_cache_node_t;
79
79
80
typedef struct util_ald_cache_t {
80
typedef struct util_ald_cache util_ald_cache_t;
81
    unsigned long size;		/* Size of cache array */
81
82
    unsigned long maxentries;	/* Maximum number of cache entries */
82
struct util_ald_cache {
83
    unsigned long numentries;	/* Current number of cache entries */
83
    unsigned long size;			/* Size of cache array */
84
    unsigned long fullmark;	/* Used to keep track of when cache becomes 3/4 full */
84
    unsigned long maxentries;		/* Maximum number of cache entries */
85
    apr_time_t marktime;	/* Time that the cache became 3/4 full */
85
    unsigned long numentries;		/* Current number of cache entries */
86
    unsigned long (*hash)(void *);  /* Func to hash the payload */
86
    unsigned long fullmark;		/* Used to keep track of when cache becomes 3/4 full */
87
    int (*compare)(void *, void *); /* Func to compare two payloads */
87
    apr_time_t marktime;		/* Time that the cache became 3/4 full */
88
    void * (*copy)(void *);	/* Func to alloc mem and copy payload to new mem */
88
    unsigned long (*hash)(void *);  		/* Func to hash the payload */
89
    void (*free)(void *);	/* Func to free mem used by the payload */
89
    int (*compare)(void *, void *); 		/* Func to compare two payloads */
90
    void * (*copy)(util_ald_cache_t *cache, void *);	/* Func to alloc mem and copy payload to new mem */
91
    void (*free)(util_ald_cache_t *cache, void *);		/* Func to free mem used by the payload */
90
    util_cache_node_t **nodes;
92
    util_cache_node_t **nodes;
91
93
92
    unsigned long numpurges;	/* No. of times the cache has been purged */
94
    unsigned long numpurges;	/* No. of times the cache has been purged */
Lines 100-123 Link Here
100
    unsigned long hits;		/* Number of cache hits */
102
    unsigned long hits;		/* Number of cache hits */
101
    unsigned long inserts;	/* Number of inserts */
103
    unsigned long inserts;	/* Number of inserts */
102
    unsigned long removes;	/* Number of removes */
104
    unsigned long removes;	/* Number of removes */
103
} util_ald_cache_t;
104
105
105
#if APR_HAS_SHARED_MEMORY
106
#if APR_HAS_SHARED_MEMORY
106
apr_shm_t *util_ldap_shm;
107
    apr_shm_t *shm_addr;
107
apr_rmm_t *util_ldap_rmm;
108
    apr_rmm_t *rmm_addr;
108
#endif
109
#endif
109
util_ald_cache_t *util_ldap_cache;
110
111
};
110
112
111
#if APR_HAS_THREADS
113
#if APR_HAS_THREADS
112
apr_thread_rwlock_t *util_ldap_cache_lock;
113
#define LDAP_CACHE_LOCK_CREATE(p) \
114
#define LDAP_CACHE_LOCK_CREATE(p) \
114
    if (!util_ldap_cache_lock) apr_thread_rwlock_create(&util_ldap_cache_lock, p)
115
    if (!st->util_ldap_cache_lock) apr_thread_rwlock_create(&st->util_ldap_cache_lock, st->pool)
115
#define LDAP_CACHE_WRLOCK() \
116
#define LDAP_CACHE_WRLOCK() \
116
    apr_thread_rwlock_wrlock(util_ldap_cache_lock)
117
    apr_thread_rwlock_wrlock(st->util_ldap_cache_lock)
117
#define LDAP_CACHE_UNLOCK() \
118
#define LDAP_CACHE_UNLOCK() \
118
    apr_thread_rwlock_unlock(util_ldap_cache_lock)
119
    apr_thread_rwlock_unlock(st->util_ldap_cache_lock)
119
#define LDAP_CACHE_RDLOCK() \
120
#define LDAP_CACHE_RDLOCK() \
120
    apr_thread_rwlock_rdlock(util_ldap_cache_lock)
121
    apr_thread_rwlock_rdlock(st->util_ldap_cache_lock)
121
#else
122
#else
122
#define LDAP_CACHE_LOCK_CREATE(p)
123
#define LDAP_CACHE_LOCK_CREATE(p)
123
#define LDAP_CACHE_WRLOCK()
124
#define LDAP_CACHE_WRLOCK()
Lines 192-226 Link Here
192
/* util_ldap_cache.c */
193
/* util_ldap_cache.c */
193
unsigned long util_ldap_url_node_hash(void *n);
194
unsigned long util_ldap_url_node_hash(void *n);
194
int util_ldap_url_node_compare(void *a, void *b);
195
int util_ldap_url_node_compare(void *a, void *b);
195
void *util_ldap_url_node_copy(void *c);
196
void *util_ldap_url_node_copy(util_ald_cache_t *cache, void *c);
196
void util_ldap_url_node_free(void *n);
197
void util_ldap_url_node_free(util_ald_cache_t *cache, void *n);
197
unsigned long util_ldap_search_node_hash(void *n);
198
unsigned long util_ldap_search_node_hash(void *n);
198
int util_ldap_search_node_compare(void *a, void *b);
199
int util_ldap_search_node_compare(void *a, void *b);
199
void *util_ldap_search_node_copy(void *c);
200
void *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c);
200
void util_ldap_search_node_free(void *n);
201
void util_ldap_search_node_free(util_ald_cache_t *cache, void *n);
201
unsigned long util_ldap_compare_node_hash(void *n);
202
unsigned long util_ldap_compare_node_hash(void *n);
202
int util_ldap_compare_node_compare(void *a, void *b);
203
int util_ldap_compare_node_compare(void *a, void *b);
203
void *util_ldap_compare_node_copy(void *c);
204
void *util_ldap_compare_node_copy(util_ald_cache_t *cache, void *c);
204
void util_ldap_compare_node_free(void *n);
205
void util_ldap_compare_node_free(util_ald_cache_t *cache, void *n);
205
unsigned long util_ldap_dn_compare_node_hash(void *n);
206
unsigned long util_ldap_dn_compare_node_hash(void *n);
206
int util_ldap_dn_compare_node_compare(void *a, void *b);
207
int util_ldap_dn_compare_node_compare(void *a, void *b);
207
void *util_ldap_dn_compare_node_copy(void *c);
208
void *util_ldap_dn_compare_node_copy(util_ald_cache_t *cache, void *c);
208
void util_ldap_dn_compare_node_free(void *n);
209
void util_ldap_dn_compare_node_free(util_ald_cache_t *cache, void *n);
209
210
210
211
211
/* util_ldap_cache_mgr.c */
212
/* util_ldap_cache_mgr.c */
212
213
213
void util_ald_free(const void *ptr);
214
/* Cache alloc and free function, dealing or not with shm */
214
void *util_ald_alloc(unsigned long size);
215
void util_ald_free(apr_rmm_t *rmm_addr, const void *ptr);
215
const char *util_ald_strdup(const char *s);
216
void *util_ald_alloc(apr_rmm_t *rmm_addr, unsigned long size);
217
const char *util_ald_strdup(apr_rmm_t *rmm_addr, const char *s);
218
219
/* Cache managing function */
216
unsigned long util_ald_hash_string(int nstr, ...);
220
unsigned long util_ald_hash_string(int nstr, ...);
217
void util_ald_cache_purge(util_ald_cache_t *cache);
221
void util_ald_cache_purge(util_ald_cache_t *cache);
218
util_url_node_t *util_ald_create_caches(util_ldap_state_t *s, const char *url);
222
util_url_node_t *util_ald_create_caches(util_ldap_state_t *s, const char *url);
219
util_ald_cache_t *util_ald_create_cache(unsigned long maxentries,
223
util_ald_cache_t *util_ald_create_cache(util_ldap_state_t *st,
220
                                unsigned long (*hashfunc)(void *), 
224
                                unsigned long (*hashfunc)(void *), 
221
                                int (*comparefunc)(void *, void *),
225
                                int (*comparefunc)(void *, void *),
222
                                void * (*copyfunc)(void *),
226
                                void * (*copyfunc)(util_ald_cache_t *cache, void *),
223
                                void (*freefunc)(void *));
227
                                void (*freefunc)(util_ald_cache_t *cache, void *));
228
                                
224
void util_ald_destroy_cache(util_ald_cache_t *cache);
229
void util_ald_destroy_cache(util_ald_cache_t *cache);
225
void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload);
230
void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload);
226
void util_ald_cache_insert(util_ald_cache_t *cache, void *payload);
231
void util_ald_cache_insert(util_ald_cache_t *cache, void *payload);
(-)modules/experimental/util_ldap_cache_mgr.c (-34 / +43 lines)
Lines 112-125 Link Here
112
  0
112
  0
113
};
113
};
114
114
115
void util_ald_free(const void *ptr)
115
void util_ald_free(apr_rmm_t *rmm_addr, const void *ptr)
116
{
116
{
117
#if APR_HAS_SHARED_MEMORY
117
#if APR_HAS_SHARED_MEMORY
118
    if (util_ldap_shm) {
118
    if (rmm_addr) {
119
        if (ptr)
119
        if (ptr)
120
            apr_rmm_free(util_ldap_rmm, apr_rmm_offset_get(util_ldap_rmm, (void *)ptr));
120
            /* Free in shared memory */
121
            apr_rmm_free(rmm_addr, apr_rmm_offset_get(rmm_addr, (void *)ptr));
121
    } else {
122
    } else {
122
        if (ptr)
123
        if (ptr)
124
            /* Cache shm is not used */
123
            free((void *)ptr);
125
            free((void *)ptr);
124
    }
126
    }
125
#else
127
#else
Lines 128-141 Link Here
128
#endif
130
#endif
129
}
131
}
130
132
131
void *util_ald_alloc(unsigned long size)
133
void *util_ald_alloc(apr_rmm_t *rmm_addr, unsigned long size)
132
{
134
{
133
    if (0 == size)
135
    if (0 == size)
134
        return NULL;
136
        return NULL;
135
#if APR_HAS_SHARED_MEMORY
137
#if APR_HAS_SHARED_MEMORY
136
    if (util_ldap_shm) {
138
    if (rmm_addr) {
137
        return (void *)apr_rmm_addr_get(util_ldap_rmm, apr_rmm_calloc(util_ldap_rmm, size));
139
        /* allocate from shared memory */
140
        return (void *)apr_rmm_addr_get(rmm_addr, apr_rmm_calloc(rmm_addr, size));
138
    } else {
141
    } else {
142
    	/* Cache shm is not used */
139
        return (void *)calloc(sizeof(char), size);
143
        return (void *)calloc(sizeof(char), size);
140
    }
144
    }
141
#else
145
#else
Lines 143-153 Link Here
143
#endif
147
#endif
144
}
148
}
145
149
146
const char *util_ald_strdup(const char *s)
150
const char *util_ald_strdup(apr_rmm_t *rmm_addr, const char *s)
147
{
151
{
148
#if APR_HAS_SHARED_MEMORY
152
#if APR_HAS_SHARED_MEMORY
149
    if (util_ldap_shm) {
153
    if (rmm_addr) {
150
        char *buf = (char *)apr_rmm_addr_get(util_ldap_rmm, apr_rmm_calloc(util_ldap_rmm, strlen(s)+1));
154
    	/* allocate from shared memory */
155
        char *buf = (char *)apr_rmm_addr_get(rmm_addr, apr_rmm_calloc(rmm_addr, strlen(s)+1));
151
        if (buf) {
156
        if (buf) {
152
            strcpy(buf, s);
157
            strcpy(buf, s);
153
            return buf;
158
            return buf;
Lines 156-161 Link Here
156
            return NULL;
161
            return NULL;
157
        }
162
        }
158
    } else {
163
    } else {
164
        /* Cache shm is not used */
159
        return strdup(s);
165
        return strdup(s);
160
    }
166
    }
161
#else
167
#else
Lines 217-224 Link Here
217
        while (p != NULL) {
223
        while (p != NULL) {
218
            if (p->add_time < cache->marktime) {
224
            if (p->add_time < cache->marktime) {
219
	        q = p->next;
225
	        q = p->next;
220
	        (*cache->free)(p->payload);
226
	        (*cache->free)(cache, p->payload);
221
	        util_ald_free(p);
227
	        util_ald_free(cache->rmm_addr, p);
222
	        cache->numentries--;
228
	        cache->numentries--;
223
	        cache->npurged++;
229
	        cache->npurged++;
224
	        p = q;
230
	        p = q;
Lines 247-263 Link Here
247
    util_ald_cache_t *dn_compare_cache;
253
    util_ald_cache_t *dn_compare_cache;
248
254
249
    /* create the three caches */
255
    /* create the three caches */
250
    search_cache = util_ald_create_cache(st->search_cache_size,
256
    search_cache = util_ald_create_cache(st,
251
					  util_ldap_search_node_hash,
257
					  util_ldap_search_node_hash,
252
					  util_ldap_search_node_compare,
258
					  util_ldap_search_node_compare,
253
					  util_ldap_search_node_copy,
259
					  util_ldap_search_node_copy,
254
					  util_ldap_search_node_free);
260
					  util_ldap_search_node_free);
255
    compare_cache = util_ald_create_cache(st->compare_cache_size,
261
    compare_cache = util_ald_create_cache(st,
256
					   util_ldap_compare_node_hash,
262
					   util_ldap_compare_node_hash,
257
					   util_ldap_compare_node_compare,
263
					   util_ldap_compare_node_compare,
258
					   util_ldap_compare_node_copy,
264
					   util_ldap_compare_node_copy,
259
					   util_ldap_compare_node_free);
265
					   util_ldap_compare_node_free);
260
    dn_compare_cache = util_ald_create_cache(st->compare_cache_size,
266
    dn_compare_cache = util_ald_create_cache(st,
261
					      util_ldap_dn_compare_node_hash,
267
					      util_ldap_dn_compare_node_hash,
262
					      util_ldap_dn_compare_node_compare,
268
					      util_ldap_dn_compare_node_compare,
263
					      util_ldap_dn_compare_node_copy,
269
					      util_ldap_dn_compare_node_copy,
Lines 272-278 Link Here
272
        curl->compare_cache = compare_cache;
278
        curl->compare_cache = compare_cache;
273
        curl->dn_compare_cache = dn_compare_cache;
279
        curl->dn_compare_cache = dn_compare_cache;
274
280
275
        util_ald_cache_insert(util_ldap_cache, curl);
281
        util_ald_cache_insert(st->util_ldap_cache, curl);
276
282
277
    }
283
    }
278
284
Lines 280-311 Link Here
280
}
286
}
281
287
282
288
283
util_ald_cache_t *util_ald_create_cache(unsigned long maxentries,
289
util_ald_cache_t *util_ald_create_cache(util_ldap_state_t *st,
284
                                unsigned long (*hashfunc)(void *), 
290
                                unsigned long (*hashfunc)(void *), 
285
                                int (*comparefunc)(void *, void *),
291
                                int (*comparefunc)(void *, void *),
286
                                void * (*copyfunc)(void *),
292
                                void * (*copyfunc)(util_ald_cache_t *cache, void *),
287
                                void (*freefunc)(void *))
293
                                void (*freefunc)(util_ald_cache_t *cache, void *))
288
{
294
{
289
    util_ald_cache_t *cache;
295
    util_ald_cache_t *cache;
290
    unsigned long i;
296
    unsigned long i;
291
297
292
    if (maxentries <= 0)
298
    if (st->search_cache_size <= 0)
293
        return NULL;
299
        return NULL;
294
300
295
    cache = (util_ald_cache_t *)util_ald_alloc(sizeof(util_ald_cache_t));
301
    cache = (util_ald_cache_t *)util_ald_alloc(st->cache_rmm, sizeof(util_ald_cache_t));
296
    if (!cache)
302
    if (!cache)
297
        return NULL;
303
        return NULL;
298
304
299
    cache->maxentries = maxentries;
305
    cache->maxentries = st->search_cache_size;
300
    cache->numentries = 0;
306
    cache->numentries = 0;
301
    cache->size = maxentries / 3;
307
    cache->size = st->search_cache_size / 3;
302
    if (cache->size < 64) cache->size = 64;
308
    if (cache->size < 64) cache->size = 64;
303
        for (i = 0; primes[i] && primes[i] < cache->size; ++i) ;
309
        for (i = 0; primes[i] && primes[i] < cache->size; ++i) ;
304
            cache->size = primes[i]? primes[i] : primes[i-1];
310
            cache->size = primes[i]? primes[i] : primes[i-1];
305
311
306
    cache->nodes = (util_cache_node_t **)util_ald_alloc(cache->size * sizeof(util_cache_node_t *));
312
    cache->nodes = (util_cache_node_t **)util_ald_alloc(cache->rmm_addr, cache->size * sizeof(util_cache_node_t *));
307
    if (!cache->nodes) {
313
    if (!cache->nodes) {
308
        util_ald_free(cache);
314
        util_ald_free(cache->rmm_addr, cache);
309
        return NULL;
315
        return NULL;
310
    }
316
    }
311
317
Lines 345-357 Link Here
345
        q = NULL;
351
        q = NULL;
346
        while (p != NULL) {
352
        while (p != NULL) {
347
            q = p->next;
353
            q = p->next;
348
           (*cache->free)(p->payload);
354
           (*cache->free)(cache, p->payload);
349
           util_ald_free(p);
355
           util_ald_free(cache->rmm_addr, p);
350
           p = q;
356
           p = q;
351
        }
357
        }
352
    }
358
    }
353
    util_ald_free(cache->nodes);
359
    util_ald_free(cache->rmm_addr, cache->nodes);
354
    util_ald_free(cache);
360
    util_ald_free(cache->rmm_addr, cache);
355
}
361
}
356
362
357
void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload)
363
void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload)
Lines 392-400 Link Here
392
398
393
    cache->inserts++;
399
    cache->inserts++;
394
    hashval = (*cache->hash)(payload) % cache->size;
400
    hashval = (*cache->hash)(payload) % cache->size;
395
    node = (util_cache_node_t *)util_ald_alloc(sizeof(util_cache_node_t));
401
    node = (util_cache_node_t *)util_ald_alloc(cache->rmm_addr, sizeof(util_cache_node_t));
396
    node->add_time = apr_time_now();
402
    node->add_time = apr_time_now();
397
    node->payload = (*cache->copy)(payload);
403
    node->payload = (*cache->copy)(cache, payload);
398
    node->next = cache->nodes[hashval];
404
    node->next = cache->nodes[hashval];
399
    cache->nodes[hashval] = node;
405
    cache->nodes[hashval] = node;
400
    if (++cache->numentries == cache->fullmark) 
406
    if (++cache->numentries == cache->fullmark) 
Lines 431-438 Link Here
431
        /* We found the node and it's not the first in the list */
437
        /* We found the node and it's not the first in the list */
432
        q->next = p->next;
438
        q->next = p->next;
433
    }
439
    }
434
    (*cache->free)(p->payload);
440
    (*cache->free)(cache, p->payload);
435
    util_ald_free(p);
441
    util_ald_free(cache->rmm_addr, p);
436
    cache->numentries--;
442
    cache->numentries--;
437
}
443
}
438
444
Lines 499-514 Link Here
499
    return buf;
505
    return buf;
500
}
506
}
501
507
502
char *util_ald_cache_display(apr_pool_t *pool)
508
char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st)
503
{
509
{
504
    unsigned long i;
510
    unsigned long i;
505
    char *buf, *t1, *t2, *t3;
511
    char *buf, *t1, *t2, *t3;
506
512
513
    util_ald_cache_t *util_ldap_cache = st->util_ldap_cache;
514
515
507
    if (!util_ldap_cache) {
516
    if (!util_ldap_cache) {
508
        return "<tr valign='top'><td nowrap colspan=7>Cache has not been enabled/initialised.</td></tr>";
517
        return "<tr valign='top'><td nowrap colspan=7>Cache has not been enabled/initialised.</td></tr>";
509
    }
518
    }
510
519
511
    buf = util_ald_cache_display_stats(pool, util_ldap_cache, "LDAP URL Cache");
520
    buf = util_ald_cache_display_stats(pool, st->util_ldap_cache, "LDAP URL Cache");
512
521
513
    for (i=0; i < util_ldap_cache->size; ++i) {
522
    for (i=0; i < util_ldap_cache->size; ++i) {
514
        util_cache_node_t *p;
523
        util_cache_node_t *p;

Return to bug 18756