From e59d43c7c95a737b1dade0affdb31f77eb6fa51b Mon Sep 17 00:00:00 2001 From: Xuefer Date: Thu, 25 May 2006 02:39:16 +0000 Subject: [PATCH] friendly anonymous mmap name for win32 git-svn-id: svn://svn.lighttpd.net/xcache/trunk@21 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- mmap.c | 9 +++++++-- xcache.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mmap.c b/mmap.c index 4e3509a..69c95ee 100644 --- a/mmap.c +++ b/mmap.c @@ -137,18 +137,23 @@ void xc_shm_destroy(xc_shm_t *shm) /* {{{ */ /* }}} */ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_protection) /* {{{ */ { +#ifdef ZEND_WIN32 +# define TMP_PATH "XCache" +#else +# define TMP_PATH "/tmp/XCache" +#endif xc_shm_t *shm = NULL; int fd = -1; int ro_ok; volatile void *romem; - char tmpname[sizeof("/tmp/xcache") - 1 + 100]; + char tmpname[sizeof(TMP_PATH) - 1 + 100]; CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM"); shm->size = size; if (path == NULL || !path[0]) { static int inc = 0; - snprintf(tmpname, sizeof(tmpname) - 1, "/tmp/xcache.%d.%d.%d", (int) getuid(), inc ++, rand()); + snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d", TMP_PATH, (int) getuid(), inc ++, rand()); path = tmpname; } diff --git a/xcache.c b/xcache.c index f1ece20..44321e6 100644 --- a/xcache.c +++ b/xcache.c @@ -1711,6 +1711,11 @@ static PHP_INI_MH(xc_OnUpdateString) #define OnUpdateInt OnUpdateLong #endif +#ifdef ZEND_WIN32 +# define DEFAULT_PATH "xcache" +#else +# define DEFAULT_PATH "/dev/zero" +#endif PHP_INI_BEGIN() PHP_INI_ENTRY1 ("xcache.size", "0", PHP_INI_SYSTEM, xc_OnUpdateLong, &xc_php_size) PHP_INI_ENTRY1 ("xcache.count", "1", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_php_hcache) @@ -1720,7 +1725,7 @@ PHP_INI_BEGIN() PHP_INI_ENTRY1 ("xcache.var_count", "1", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_var_hcache) PHP_INI_ENTRY1 ("xcache.var_slots", "8K", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_var_hentry) - PHP_INI_ENTRY1 ("xcache.mmap_path", "/dev/zero", PHP_INI_SYSTEM, xc_OnUpdateString, &xc_mmap_path) + PHP_INI_ENTRY1 ("xcache.mmap_path", DEFAULT_PATH, PHP_INI_SYSTEM, xc_OnUpdateString, &xc_mmap_path) PHP_INI_ENTRY1 ("xcache.coredump_directory", "", PHP_INI_SYSTEM, xc_OnUpdateString, &xc_coredump_dir) PHP_INI_ENTRY1 ("xcache.test", "0", PHP_INI_SYSTEM, xc_OnUpdateBool, &xc_test) PHP_INI_ENTRY1 ("xcache.readonly_protection", "0", PHP_INI_SYSTEM, xc_OnUpdateBool, &xc_readonly_protection) @@ -1820,7 +1825,7 @@ static PHP_MINIT_FUNCTION(xcache) if ((xc_php_size || xc_var_size) && xc_mmap_path && xc_mmap_path[0]) { if (!xc_init(module_number TSRMLS_CC)) { - zend_error(E_ERROR, "XCache: Cannot init xcache"); + zend_error(E_ERROR, "XCache: Cannot init"); goto err_init; } xc_initized = 1; @@ -1891,7 +1896,7 @@ static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xcache) zend_module_entry xcache_module_entry = { STANDARD_MODULE_HEADER, - "xcache", + "XCache", xcache_functions, PHP_MINIT(xcache), PHP_MSHUTDOWN(xcache),