Browse Source

fix win32 emulated anonymous mmap

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.0@83 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.0
Xuefer 16 years ago
parent
commit
9980dfc47a
  1. 10
      mmap.c

10
mmap.c

@ -11,6 +11,7 @@
#ifdef ZEND_WIN32
# define ftruncate chsize
# define getuid() 0
# include <process.h>
# define XCacheCreateFileMapping(size, perm, name) \
CreateFileMapping(INVALID_HANDLE_VALUE, NULL, perm, (sizeof(xc_shmsize_t) > 4) ? size >> 32 : 0, size & 0xffffffff, name)
# define XCACHE_MAP_FAILED NULL
@ -156,9 +157,16 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
if (path == NULL || !path[0]) {
static int inc = 0;
snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d", TMP_PATH, (int) getuid(), inc ++, rand());
snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d.%d", TMP_PATH, (int) getuid(), (int) getpid(), inc ++, rand());
path = tmpname;
}
#ifdef ZEND_WIN32
else {
static int inc2 = 0;
snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d.%d", path, (int) getuid(), (int) getpid(), inc2 ++, rand());
path = tmpname;
}
#endif
shm->name = strdup(path);

Loading…
Cancel
Save