Index: /trunk/xcache/xc_lock.c
===================================================================
--- /trunk/xcache/xc_lock.c	(revision 1153)
+++ /trunk/xcache/xc_lock.c	(revision 1154)
@@ -88,5 +88,5 @@
 
 	if (pathname == NULL) {
-		static int i = 0;
+		static int instanceId = 0;
 		const char default_tmpdir[] = { DEFAULT_SLASH, 't', 'm', 'p', '\0' };
 		const char *tmpdir;
@@ -101,5 +101,5 @@
 		size = strlen(tmpdir) + sizeof("/.xcache.lock") - 1 + 3 * 10 + 100;
 		myname = malloc(size);
-		snprintf(myname, size - 1, "%s%c.xcache.%d.%d.%d.lock", tmpdir, DEFAULT_SLASH, (int) getuid(), i ++, rand());
+		snprintf(myname, size - 1, "%s%c.xcache.%d.%d.%d.lock", tmpdir, DEFAULT_SLASH, (int) getuid(), (int) getpid(), ++instanceId);
 		pathname = myname;
 	}
Index: /trunk/xcache/xc_shm_mmap.c
===================================================================
--- /trunk/xcache/xc_shm_mmap.c	(revision 1153)
+++ /trunk/xcache/xc_shm_mmap.c	(revision 1154)
@@ -151,7 +151,8 @@
 	int ro_ok;
 	volatile void *romem;
-	char tmpname[sizeof(TMP_PATH) - 1 + 100];
+	char tmpname[sizeof(TMP_PATH) - 1 + 4 * 10 + 100] = { 0 };
 	const char *errstr = NULL;
 	const char *path = (const char *) arg1;
+	static int instanceId = 0;
 
 	CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM");
@@ -159,12 +160,10 @@
 
 	if (path == NULL || !path[0]) {
-		static int inc = 0;
-		snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d.%d", TMP_PATH, (int) getuid(), (int) getpid(), inc ++, rand());
+		snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d", TMP_PATH, (int) getuid(), (int) getpid(), ++instanceId);
 		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());
+		snprintf(tmpname, sizeof(tmpname) - 1, "%s.%d.%d.%d", path, (int) getuid(), (int) getpid(), ++instanceId);
 		path = tmpname;
 	}
