Move session table initialization into session file.

This moves all the code working on the session table to that file.
This commit is contained in:
Olav Morken 2014-08-27 15:02:46 +02:00
parent eda061bcc3
commit 4062e36456
3 changed files with 23 additions and 7 deletions

View File

@ -329,6 +329,7 @@ void am_cookie_set(request_rec *r, const char *id);
void am_cookie_delete(request_rec *r);
void am_cache_init(am_mod_cfg_rec *mod_cfg);
am_cache_entry_t *am_cache_lock(server_rec *s,
am_cache_key_t type, const char *key);
const char *am_cache_entry_get_string(am_cache_entry_t *e,

View File

@ -21,6 +21,26 @@
#include "auth_mellon.h"
/* Initialize the session table.
*
* Parameters:
* am_mod_cfg_rec *mod_cfg The module configuration.
*
* Returns:
* Nothing.
*/
void am_cache_init(am_mod_cfg_rec *mod_cfg)
{
am_cache_entry_t *table;
int i;
/* Initialize the session table. */
table = apr_shm_baseaddr_get(mod_cfg->cache);
for (i = 0; i < mod_cfg->init_cache_size; i++) {
table[i].key[0] = '\0';
table[i].access = 0;
}
}
/* This function locks the session table and locates a session entry.
* Unlocks the table and returns NULL if the entry wasn't found.
* If a entry was found, then you _must_ unlock it with am_cache_unlock

View File

@ -45,10 +45,9 @@
static int am_global_init(apr_pool_t *conf, apr_pool_t *log,
apr_pool_t *tmp, server_rec *s)
{
am_cache_entry_t *table;
apr_size_t mem_size;
am_mod_cfg_rec *mod;
int rv, i;
int rv;
const char userdata_key[] = "auth_mellon_init";
char buffer[512];
void *data;
@ -108,11 +107,7 @@ static int am_global_init(apr_pool_t *conf, apr_pool_t *log,
}
/* Initialize the session table. */
table = apr_shm_baseaddr_get(mod->cache);
for (i = 0; i < mod->init_cache_size; i++) {
table[i].key[0] = '\0';
table[i].access = 0;
}
am_cache_init(mod);
/* Now create the mutex that we need for locking the shared memory, then
* test for success. we really need this, so we exit on failure. */