diff options
author | Joe Orton <jorton@apache.org> | 2016-04-08 13:02:14 +0200 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2016-04-08 13:02:14 +0200 |
commit | bf5205907b4b73c5a4e27183ece42834c718d502 (patch) | |
tree | 9cf56369a9f257d604a4de58476ec9ef13084f94 /modules/lua | |
parent | Documentation rebuild (diff) | |
download | apache2-bf5205907b4b73c5a4e27183ece42834c718d502.tar.xz apache2-bf5205907b4b73c5a4e27183ece42834c718d502.zip |
* modules/lua/mod_lua.c (lua_post_config): Use anonymous shm segment
in preference to named segment. Ensure startup is possible after an
unclean shutdown.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1738229 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/lua')
-rw-r--r-- | modules/lua/mod_lua.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c index dcb38e3ef6..628f8ee51b 100644 --- a/modules/lua/mod_lua.c +++ b/modules/lua/mod_lua.c @@ -83,6 +83,8 @@ typedef struct int broken; } lua_filter_ctx; +#define DEFAULT_LUA_SHMFILE "lua_ivm_shm" + apr_global_mutex_t *lua_ivm_mutex; apr_shm_t *lua_ivm_shm; char *lua_ivm_shmfile; @@ -1995,7 +1997,6 @@ static int lua_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { apr_pool_t **pool; - const char *tempdir; apr_status_t rs; lua_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup); @@ -2011,21 +2012,20 @@ static int lua_post_config(apr_pool_t *pconf, apr_pool_t *plog, return HTTP_INTERNAL_SERVER_ERROR; } - /* Create shared memory space */ - rs = apr_temp_dir_get(&tempdir, pconf); - if (rs != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, APLOGNO(02664) - "mod_lua IVM: Failed to find temporary directory"); - return HTTP_INTERNAL_SERVER_ERROR; + /* Create shared memory space, anonymous first if possible. */ + rs = apr_shm_create(&lua_ivm_shm, sizeof pool, NULL, pconf); + if (APR_STATUS_IS_ENOTIMPL(rs)) { + /* Fall back to filename-based; nuke any left-over first. */ + lua_ivm_shmfile = ap_runtime_dir_relative(pconf, DEFAULT_LUA_SHMFILE); + + apr_shm_remove(lua_ivm_shmfile, pconf); + + rs = apr_shm_create(&lua_ivm_shm, sizeof pool, lua_ivm_shmfile, pconf); } - lua_ivm_shmfile = apr_psprintf(pconf, "%s/httpd_lua_shm.%ld", tempdir, - (long int)getpid()); - rs = apr_shm_create(&lua_ivm_shm, sizeof(apr_pool_t**), - (const char *) lua_ivm_shmfile, pconf); if (rs != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, APLOGNO(02665) "mod_lua: Failed to create shared memory segment on file %s", - lua_ivm_shmfile); + lua_ivm_shmfile ? lua_ivm_shmfile : "(anonymous)"); return HTTP_INTERNAL_SERVER_ERROR; } pool = (apr_pool_t **)apr_shm_baseaddr_get(lua_ivm_shm); |