Index: trunk/xcache.c
===================================================================
--- trunk/xcache.c	(revision 403)
+++ trunk/xcache.c	(revision 405)
@@ -87,4 +87,5 @@
 
 static zend_bool xc_initized = 0;
+static zend_compile_file_t *origin_compile_file = NULL;
 static zend_compile_file_t *old_compile_file = NULL;
 static zend_llist_element  *xc_llist_zend_extension = NULL;
@@ -974,4 +975,6 @@
 	old_constinfo_cnt = zend_hash_num_elements(EG(zend_constants));
 
+	php->op_array = NULL;
+	XG(initial_compile_file_called) = 0;
 	zend_try {
 		op_array = old_compile_file(h, type TSRMLS_CC);
@@ -986,4 +989,8 @@
 	if (op_array == NULL) {
 		goto err_op_array;
+	}
+
+	if (!XG(initial_compile_file_called)) {
+		return op_array;
 	}
 
@@ -1164,4 +1171,10 @@
 }
 /* }}} */
+static zend_op_array *xc_check_initial_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
+{
+	XG(initial_compile_file_called) = 1;
+	return origin_compile_file(h, type TSRMLS_CC);
+}
+/* }}} */
 static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
 {
@@ -1290,4 +1303,11 @@
 		}
 
+		/* not cachable */
+		if (!php.op_array) {
+			cache->compiling = 0;
+			xc_sandbox_free(&sandbox, XC_InstallNoBinding TSRMLS_CC);
+			return op_array;
+		}
+
 		xce.data.php = &php;
 	}
@@ -1355,5 +1375,5 @@
 		}
 		if (newlycompiled) {
-			xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+			xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 		}
 		return xc_compile_restore(stored_xce, h TSRMLS_CC);
@@ -1363,5 +1383,5 @@
 			/* install it */
 			CG(active_op_array) = op_array;
-			xc_sandbox_free(&sandbox, 1 TSRMLS_CC);
+			xc_sandbox_free(&sandbox, XC_Install TSRMLS_CC);
 		}
 	}
@@ -1371,5 +1391,5 @@
 	if (newlycompiled) {
 		xc_free_php(&php TSRMLS_CC);
-		xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+		xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 	}
 
@@ -1564,4 +1584,9 @@
 		zend_compile_file = old_compile_file;
 		old_compile_file = NULL;
+	}
+
+	if (origin_compile_file) {
+		zend_compile_file = origin_compile_file;
+		origin_compile_file = NULL;
 	}
 
@@ -2915,5 +2940,5 @@
 #endif
 /* }}} */
-static startup_func_t xc_last_ext_startup = NULL;
+static startup_func_t xc_last_ext_startup;
 static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
 {
@@ -2936,4 +2961,10 @@
 {
 	xc_zend_extension_gotup = 1;
+
+	if (!origin_compile_file) {
+		origin_compile_file = zend_compile_file;
+		zend_compile_file = xc_check_initial_compile_file;
+	}
+
 	if (zend_llist_count(&zend_extensions) > 1) {
 		zend_llist_position lpos;
