summaryrefslogtreecommitdiffstats
path: root/auth_mellon_cache.c
diff options
context:
space:
mode:
authorolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2008-10-20 11:50:17 +0000
committerolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2008-10-20 11:50:17 +0000
commit9aaaf79f05926ca21c69a6198f78c560bedbe5a8 (patch)
treeafd6faf2f5a754c1f03dc91cfce7f2061cb57cd2 /auth_mellon_cache.c
parent4a11abb0766232162d57096cfaea7445fd60a3d0 (diff)
downloadmod_auth_mellon-9aaaf79f05926ca21c69a6198f78c560bedbe5a8.tar.gz
mod_auth_mellon-9aaaf79f05926ca21c69a6198f78c560bedbe5a8.tar.xz
mod_auth_mellon-9aaaf79f05926ca21c69a6198f78c560bedbe5a8.zip
Handle errors when locking session mutex.
In some cases it is possible that the mutex lock operation fails. This makes the server return a 500 Internal Server Error in those cases, instead of crashing. Thanks to Emmanuel Dreyfus for the patch. git-svn-id: https://modmellon.googlecode.com/svn/trunk@28 a716ebb1-153a-0410-b759-cfb97c6a1b53
Diffstat (limited to 'auth_mellon_cache.c')
-rw-r--r--auth_mellon_cache.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c
index e1593dd..749a817 100644
--- a/auth_mellon_cache.c
+++ b/auth_mellon_cache.c
@@ -38,6 +38,8 @@ am_cache_entry_t *am_cache_lock(server_rec *s, const char *key)
am_mod_cfg_rec *mod_cfg;
am_cache_entry_t *table;
int i;
+ int rv;
+ char buffer[512];
/* Check if we have a valid session key. We abort if we don't. */
@@ -50,7 +52,13 @@ am_cache_entry_t *am_cache_lock(server_rec *s, const char *key)
/* Lock the table. */
- apr_global_mutex_lock(mod_cfg->lock);
+ 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);
@@ -95,6 +103,8 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key)
apr_time_t current_time;
int i;
apr_time_t age;
+ int rv;
+ char buffer[512];
/* Check if we have a valid session key. We abort if we don't. */
if(key == NULL || strlen(key) != AM_SESSION_ID_LENGTH) {
@@ -115,7 +125,13 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key)
/* Lock the table. */
- apr_global_mutex_lock(mod_cfg->lock);
+ 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);
/* Get current time. If we find a entry with expires <= the current