From 998157ac57ffe768a4023f22f32886aba5bcbcbd Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 12 Feb 2019 12:34:03 +0100 Subject: [PATCH] use mkstemp instead of mktemp x --- apc_lock.c | 4 ++-- apc_mmap.c | 24 ------------------------ 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/apc_lock.c b/apc_lock.c index d447b780..70ca745b 100644 --- a/apc_lock.c +++ b/apc_lock.c @@ -281,8 +281,8 @@ PHP_APCU_API void apc_lock_cleanup() { PHP_APCU_API zend_bool apc_lock_create(apc_lock_t *lock) { char lock_path[] = "/tmp/.apc.XXXXXX"; - mktemp(lock_path); - *lock = open(lock_path, O_RDWR|O_CREAT, 0666); + + *lock = mkstemp(lock_path); if (*lock > 0) { unlink(lock_path); return 1; diff --git a/apc_mmap.c b/apc_mmap.c index 9ea531d4..b56658a2 100644 --- a/apc_mmap.c +++ b/apc_mmap.c @@ -80,30 +80,6 @@ apc_segment_t apc_mmap(char *file_mask, size_t size) #ifdef APC_MEMPROTECT remap = 0; /* cannot remap */ #endif - } else if(strstr(file_mask,".shm")) { - /* - * If the filemask contains .shm we try to do a POSIX-compliant shared memory - * backed mmap which should avoid synchs on some platforms. At least on - * FreeBSD this implies MAP_NOSYNC and on Linux it is equivalent of mmap'ing - * a file in a mounted shmfs. For this to work on Linux you need to make sure - * you actually have shmfs mounted. Also on Linux, make sure the file_mask you - * pass in has a leading / and no other /'s. eg. /apc.shm.XXXXXX - * On FreeBSD these are mapped onto the regular filesystem so you can put whatever - * path you want here. - */ - if(!mktemp(file_mask)) { - zend_error_noreturn(E_CORE_ERROR, "apc_mmap: mktemp on %s failed", file_mask); - } - fd = shm_open(file_mask, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); - if(fd == -1) { - zend_error_noreturn(E_CORE_ERROR, "apc_mmap: shm_open on %s failed", file_mask); - } - if (ftruncate(fd, size) < 0) { - close(fd); - shm_unlink(file_mask); - zend_error_noreturn(E_CORE_ERROR, "apc_mmap: ftruncate failed"); - } - shm_unlink(file_mask); } else { /* * Otherwise we do a normal filesystem mmap