From: Aaron Bannert Date: Mon, 6 May 2002 18:24:03 +0000 (+0000) Subject: Fix mod_rewrite hang when APR uses SysV Semaphores. Before we were X-Git-Tag: 2.0.37~479 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28ef5dd6415c94600a43d753d7765cc2c22edb14;p=apache Fix mod_rewrite hang when APR uses SysV Semaphores. Before we were silently failing when locking/unlocking the mutex, since httpd child processes didn't have permissions to access the root-created semaphore. PR: 8143 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94969 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index bde7016116..fe5e3a6346 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -964,7 +964,19 @@ static int post_config(apr_pool_t *p, return HTTP_INTERNAL_SERVER_ERROR; } - rewritelock_create(s, p); + rv = unixd_set_global_mutex_perms(rewrite_log_lock); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, + "mod_rewrite: Could not set permissions on " + "rewrite_log_lock; check User and Group directives"); + return HTTP_INTERNAL_SERVER_ERROR; + } + + rv = rewritelock_create(s, p); + if (rv != APR_SUCCESS) { + return HTTP_INTERNAL_SERVER_ERROR; + } + apr_pool_cleanup_register(p, (void *)s, rewritelock_remove, apr_pool_cleanup_null); /* step through the servers and @@ -3296,26 +3308,34 @@ static char *current_logtime(request_rec *r) #define REWRITELOCK_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD ) -static void rewritelock_create(server_rec *s, apr_pool_t *p) +static apr_status_t rewritelock_create(server_rec *s, apr_pool_t *p) { apr_status_t rc; /* only operate if a lockfile is used */ if (lockname == NULL || *(lockname) == '\0') { - return; + return APR_EINVAL; } /* create the lockfile */ rc = apr_global_mutex_create(&rewrite_mapr_lock_acquire, lockname, APR_LOCK_DEFAULT, p); if (rc != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, + ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s, "mod_rewrite: Parent could not create RewriteLock " "file %s", lockname); - exit(1); + return rc; } - return; + rc = unixd_set_global_mutex_perms(rewrite_mapr_lock_acquire); + if (rc != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s, + "mod_rewrite: Parent could not set permissions " + "on RewriteLock; check User and Group directives"); + return rc; + } + + return APR_SUCCESS; } static apr_status_t rewritelock_remove(void *data) diff --git a/modules/mappers/mod_rewrite.h b/modules/mappers/mod_rewrite.h index f325dd8f0e..7590c11278 100644 --- a/modules/mappers/mod_rewrite.h +++ b/modules/mappers/mod_rewrite.h @@ -451,7 +451,7 @@ static void rewritelog(request_rec *r, int level, const char *text, ...) static char *current_logtime(request_rec *r); /* rewriting lockfile support */ -static void rewritelock_create(server_rec *s, apr_pool_t *p); +static apr_status_t rewritelock_create(server_rec *s, apr_pool_t *p); static apr_status_t rewritelock_remove(void *data); /* program map support */