Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 1029)
+++ /trunk/xcache.c	(revision 1030)
@@ -1638,4 +1638,5 @@
 
 	if (!XG(initial_compile_file_called)) {
+		TRACE("%s", "!initial_compile_file_called, give up");
 		return;
 	}
@@ -2439,7 +2440,4 @@
 
 		if (xc_php_size) {
-			old_compile_file = zend_compile_file;
-			zend_compile_file = xc_compile_file;
-
 			CHECK(xc_php_caches = xc_cache_init(xc_shm, &xc_php_hcache, &xc_php_hentry, &xc_php_hentry, xc_php_size), "failed init opcode cache");
 		}
@@ -3525,6 +3523,14 @@
 #endif
 
+static void xc_zend_startup_last() /* {{{ */
+{
+	if (xc_php_size) {
+		old_compile_file = zend_compile_file;
+		zend_compile_file = xc_compile_file;
+	}
+}
+/* }}} */
 static startup_func_t xc_last_ext_startup;
-static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
+static int xc_zend_startup_last_hook(zend_extension *extension) /* {{{ */
 {
 	zend_extension *ext = zend_get_extension(XCACHE_NAME);
@@ -3541,4 +3547,6 @@
 	assert(xc_llist_zend_extension);
 	xcache_llist_prepend(&zend_extensions, xc_llist_zend_extension);
+
+	xc_zend_startup_last();
 	return SUCCESS;
 }
@@ -3546,8 +3554,6 @@
 static int xc_zend_startup(zend_extension *extension) /* {{{ */
 {
-	if (!origin_compile_file) {
-		origin_compile_file = zend_compile_file;
-		zend_compile_file = xc_check_initial_compile_file;
-	}
+	origin_compile_file = zend_compile_file;
+	zend_compile_file = xc_check_initial_compile_file;
 
 	if (zend_llist_count(&zend_extensions) > 1) {
@@ -3559,5 +3565,7 @@
 			zend_error(E_WARNING, "XCache failed to load itself as the first zend_extension. compatibility downgraded");
 		}
+
 		/* hide myself */
+		/* TODO: hide handle sub modules */
 		xcache_llist_unlink(&zend_extensions, xc_llist_zend_extension);
 
@@ -3565,5 +3573,8 @@
 		assert(ext && ext != (zend_extension *) xc_llist_zend_extension->data);
 		xc_last_ext_startup = ext->startup;
-		ext->startup = xc_zend_startup_last;
+		ext->startup = xc_zend_startup_last_hook;
+	}
+	else {
+		xc_zend_startup_last();
 	}
 	return SUCCESS;
