diff options
author | olavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2009-12-21 14:06:18 +0000 |
---|---|---|
committer | olavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53> | 2009-12-21 14:06:18 +0000 |
commit | 473c061d10814224720fd2ff33badc8e9c30701f (patch) | |
tree | e1ba5cd42948710c7d19337ba0387ba411abd965 | |
parent | 684eca966d7309f4114f9d25201a270fe963b2fe (diff) | |
download | mod_auth_mellon-473c061d10814224720fd2ff33badc8e9c30701f.tar.gz mod_auth_mellon-473c061d10814224720fd2ff33badc8e9c30701f.tar.xz mod_auth_mellon-473c061d10814224720fd2ff33badc8e9c30701f.zip |
Remove unnecessary code from session creation code.
This patch fixes a spurious warning about an uninitialized
variable by removing the code path that the compiler assumed
could lead to the variable being uninitialized.
git-svn-id: https://modmellon.googlecode.com/svn/trunk@76 a716ebb1-153a-0410-b759-cfb97c6a1b53
-rw-r--r-- | auth_mellon_cache.c | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c index ba551b1..958c11a 100644 --- a/auth_mellon_cache.c +++ b/auth_mellon_cache.c @@ -145,68 +145,59 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key) } - /* First we try to find another session with the given key. */ - t = am_cache_lock(s, AM_CACHE_SESSION, key); - - - if(t == NULL) { - /* We didn't find a previous session with the key. We will search - * for the least recently used entry or a free entry in stead. - */ - - mod_cfg = am_get_mod_cfg(s); + mod_cfg = am_get_mod_cfg(s); - /* Lock the table. */ - if((rv = apr_global_mutex_lock(mod_cfg->lock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, - "apr_global_mutex_lock() failed [%d]: %s", - rv, apr_strerror(rv, buffer, sizeof(buffer))); - return NULL; - } + /* Lock the table. */ + if((rv = apr_global_mutex_lock(mod_cfg->lock)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, + "apr_global_mutex_lock() failed [%d]: %s", + rv, apr_strerror(rv, buffer, sizeof(buffer))); + return NULL; + } - table = apr_shm_baseaddr_get(mod_cfg->cache); + table = apr_shm_baseaddr_get(mod_cfg->cache); - /* Get current time. If we find a entry with expires <= the current - * time, then we can use it. - */ - current_time = apr_time_now(); + /* Get current time. If we find a entry with expires <= the current + * time, then we can use it. + */ + current_time = apr_time_now(); - /* We will use 't' to remember the best/oldest entry. We - * initalize it to the first entry in the table to simplify the - * following code (saves test for t == NULL). - */ - t = &table[0]; + /* We will use 't' to remember the best/oldest entry. We + * initalize it to the first entry in the table to simplify the + * following code (saves test for t == NULL). + */ + t = &table[0]; - /* Iterate over the session table. Update 't' to match the "best" - * entry (the least recently used). 't' will point a free entry - * if we find one. Otherwise, 't' will point to the least recently - * used entry. - */ - for(i = 0; i < mod_cfg->init_cache_size; i++) { - if(table[i].key[0] == '\0') { - /* This entry is free. Update 't' to this entry - * and exit loop. - */ - t = &table[i]; - break; - } + /* Iterate over the session table. Update 't' to match the "best" + * entry (the least recently used). 't' will point a free entry + * if we find one. Otherwise, 't' will point to the least recently + * used entry. + */ + for(i = 0; i < mod_cfg->init_cache_size; i++) { + if(table[i].key[0] == '\0') { + /* This entry is free. Update 't' to this entry + * and exit loop. + */ + t = &table[i]; + break; + } - if(table[i].expires <= current_time) { - /* This entry is expired, and is therefore free. - * Update 't' and exit loop. - */ - t = &table[i]; - break; - } + if(table[i].expires <= current_time) { + /* This entry is expired, and is therefore free. + * Update 't' and exit loop. + */ + t = &table[i]; + break; + } - if(table[i].access < t->access) { - /* This entry is older than 't' - update 't'. */ - t = &table[i]; - } + if(table[i].access < t->access) { + /* This entry is older than 't' - update 't'. */ + t = &table[i]; } } + if(t->key[0] != '\0' && t->expires > current_time) { /* We dropped a LRU entry. Calculate the age in seconds. */ age = (current_time - t->access) / 1000000; |