summaryrefslogtreecommitdiff
path: root/ext/opcache
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-12-11 17:39:57 +0100
committerAnatol Belski <ab@php.net>2015-12-11 17:39:57 +0100
commit157d0372e01e600535a9ec9a62c19b8bc41ae6e8 (patch)
treeb8bdb3b466198b4d9a94471dd36e59a0b40bebe3 /ext/opcache
parentd403a91c6fb1d91db6e363502ad96023b08f92f8 (diff)
downloadphp-git-157d0372e01e600535a9ec9a62c19b8bc41ae6e8.tar.gz
backported 7c981192eb26fbb93be767cd6b2dc765d370bbab from 7.0
the way it doesn't hurt BC
Diffstat (limited to 'ext/opcache')
-rw-r--r--ext/opcache/shared_alloc_win32.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c
index fd5d334269..171bd0d25c 100644
--- a/ext/opcache/shared_alloc_win32.c
+++ b/ext/opcache/shared_alloc_win32.c
@@ -26,6 +26,9 @@
#include <process.h>
#include <LMCONS.H>
+#include "main/php.h"
+#include "ext/standard/md5.h"
+
#define ACCEL_FILEMAP_NAME "ZendOPcache.SharedMemoryArea"
#define ACCEL_MUTEX_NAME "ZendOPcache.SharedMemoryMutex"
#define ACCEL_FILEMAP_BASE_DEFAULT 0x01000000
@@ -74,20 +77,59 @@ static void zend_win_error_message(int type, char *msg, int err)
zend_accel_error(type, msg);
}
+/* Backported from 7.0, the way no globals are touched which means win32
+ only where it's essentially needed. */
+#define ZEND_BIN_ID "BIN_" ZEND_TOSTR(SIZEOF_CHAR) ZEND_TOSTR(SIZEOF_INT) ZEND_TOSTR(SIZEOF_LONG) ZEND_TOSTR(SIZEOF_SIZE_T) ZEND_TOSTR(SIZEOF_ZEND_LONG) ZEND_TOSTR(ZEND_MM_ALIGNMENT)
+static char *accel_gen_system_id(void)
+{
+ PHP_MD5_CTX context;
+ unsigned char digest[16], c;
+ int i;
+ static char md5str[32];
+ static zend_bool done = 0;
+
+ if (done) {
+ return md5str;
+ }
+
+ PHP_MD5Init(&context);
+ PHP_MD5Update(&context, PHP_VERSION, sizeof(PHP_VERSION)-1);
+ PHP_MD5Update(&context, ZEND_EXTENSION_BUILD_ID, sizeof(ZEND_EXTENSION_BUILD_ID)-1);
+ PHP_MD5Update(&context, ZEND_BIN_ID, sizeof(ZEND_BIN_ID)-1);
+ if (strstr(PHP_VERSION, "-dev") != 0) {
+ /* Development versions may be changed from build to build */
+ PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1);
+ PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1);
+ }
+ PHP_MD5Final(digest, &context);
+ for (i = 0; i < 16; i++) {
+ c = digest[i] >> 4;
+ c = (c <= 9) ? c + '0' : c - 10 + 'a';
+ md5str[i * 2] = c;
+ c = digest[i] & 0x0f;
+ c = (c <= 9) ? c + '0' : c - 10 + 'a';
+ md5str[(i * 2) + 1] = c;
+ }
+
+ done = 1;
+
+ return md5str;
+}
+
static char *create_name_with_username(char *name)
{
- static char newname[MAXPATHLEN + UNLEN + 4];
+ static char newname[MAXPATHLEN + UNLEN + 4 + 1 + 32];
char uname[UNLEN + 1];
DWORD unsize = UNLEN;
GetUserName(uname, &unsize);
- snprintf(newname, sizeof(newname) - 1, "%s@%s", name, uname);
+ snprintf(newname, sizeof(newname) - 1, "%s@%s@%.32s", name, uname, accel_gen_system_id());
return newname;
}
static char *get_mmap_base_file(void)
{
- static char windir[MAXPATHLEN+UNLEN + 3 + sizeof("\\\\@")];
+ static char windir[MAXPATHLEN+UNLEN + 3 + sizeof("\\\\@") + 1 + 32];
char uname[UNLEN + 1];
DWORD unsize = UNLEN;
int l;
@@ -95,7 +137,7 @@ static char *get_mmap_base_file(void)
GetTempPath(MAXPATHLEN, windir);
GetUserName(uname, &unsize);
l = strlen(windir);
- snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%s", ACCEL_FILEMAP_BASE, uname);
+ snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%s@%.32s", ACCEL_FILEMAP_BASE, uname, accel_gen_system_id());
return windir;
}