Index: trunk/xcache.c
===================================================================
--- trunk/xcache.c	(revision 931)
+++ trunk/xcache.c	(revision 936)
@@ -281,4 +281,5 @@
 	if (stored_entry) {
 		xc_entry_add_unlocked(cache, entryslotid, stored_entry);
+		++cache->updates;
 		return stored_entry;
 	}
@@ -592,5 +593,6 @@
 	add_assoc_long_ex(return_value, ZEND_STRS("slots"),     cache->hentry->size);
 	add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cache->compiling);
-	add_assoc_long_ex(return_value, ZEND_STRS("misses"),    cache->misses);
+	add_assoc_long_ex(return_value, ZEND_STRS("updates"),   cache->updates);
+	add_assoc_long_ex(return_value, ZEND_STRS("misses"),    cache->updates); /* deprecated */
 	add_assoc_long_ex(return_value, ZEND_STRS("hits"),      cache->hits);
 	add_assoc_long_ex(return_value, ZEND_STRS("clogs"),     cache->clogs);
@@ -1601,7 +1603,6 @@
 }
 /* }}} */
-static zend_op_array *xc_compile_php(xc_compiler_t *compiler, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
-{
-	zend_op_array *op_array;
+static void xc_compile_php(xc_compiler_t *compiler, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
+{
 	zend_uint old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt;
 	zend_bool catched = 0;
@@ -1614,8 +1615,6 @@
 	old_constinfo_cnt = zend_hash_num_elements(EG(zend_constants));
 
-	compiler->new_php.op_array = NULL;
-	XG(initial_compile_file_called) = 0;
 	zend_try {
-		op_array = old_compile_file(h, type TSRMLS_CC);
+		compiler->new_php.op_array = old_compile_file(h, type TSRMLS_CC);
 	} zend_catch {
 		catched = 1;
@@ -1626,10 +1625,10 @@
 	}
 
-	if (op_array == NULL) {
+	if (compiler->new_php.op_array == NULL) {
 		goto err_op_array;
 	}
 
 	if (!XG(initial_compile_file_called)) {
-		return op_array;
+		return;
 	}
 
@@ -1637,5 +1636,4 @@
 	/* {{{ prepare */
 	zend_restore_compiled_filename(h->opened_path ? h->opened_path : (char *) h->filename TSRMLS_CC);
-	compiler->new_php.op_array = op_array;
 
 #ifdef HAVE_XCACHE_CONSTANT
@@ -1819,5 +1817,5 @@
 #endif
 
-	return op_array;
+	return;
 
 err_alloc:
@@ -1830,6 +1828,4 @@
 		zend_bailout();
 	}
-
-	return op_array;
 }
 /* }}} */
@@ -1912,5 +1908,4 @@
 	*/
 
-	zend_op_array *op_array;
 	xc_entry_php_t *stored_entry;
 	xc_entry_data_php_t *stored_php;
@@ -1956,5 +1951,4 @@
 		}
 
-		cache->misses ++;
 		TRACE("miss entry %d:%s", compiler->new_entry.file_inode, compiler->new_entry.entry.name.str.val);
 
@@ -2008,8 +2002,6 @@
 	/* }}} */
 
-	op_array = NULL;
 	/* {{{ compile */
 	/* make compile inside sandbox */
-	xc_sandbox_init(&sandbox, h->opened_path ? h->opened_path : h->filename TSRMLS_CC);
 
 #ifdef HAVE_XCACHE_CONSTANT
@@ -2023,22 +2015,19 @@
 	memset(&compiler->new_php.op_array_info, 0, sizeof(compiler->new_php.op_array_info));
 
+	XG(initial_compile_file_called) = 0;
 	zend_try {
-		op_array = xc_compile_php(compiler, h, type TSRMLS_CC);
+		xc_sandbox_init(&sandbox, h->opened_path ? h->opened_path : h->filename TSRMLS_CC);
+		compiler->new_php.op_array = NULL;
+		xc_compile_php(compiler, h, type TSRMLS_CC);
 	} zend_catch {
 		catched = 1;
 	} zend_end_try();
 
-	if (catched || !op_array) {
+	if (catched
+	 || !compiler->new_php.op_array /* possible ? */
+	 || !XG(initial_compile_file_called)) {
 		goto err_aftersandbox;
 	}
 
-	/* not cachable */
-	if (!compiler->new_php.op_array) {
-		cache->compiling = 0;
-		/* it's not cachable, but don't scare the users with high misses */
-		cache->misses --;
-		xc_sandbox_free(&sandbox, XC_InstallNoBinding TSRMLS_CC);
-		return op_array;
-	}
 	/* }}} */
 #ifdef SHOW_DPRINT
@@ -2065,19 +2054,20 @@
 	TRACE("%s", stored_entry ? "stored" : "store failed");
 
+	if (catched || !stored_php) {
+		goto err_aftersandbox;
+	}
+
 	cache->compiling = 0;
-	if (catched) {
-		goto err_aftersandbox;
-	}
-
 	xc_free_php(&compiler->new_php TSRMLS_CC);
 
 	if (stored_entry) {
-		if (op_array) {
+		if (compiler->new_php.op_array) {
 #ifdef ZEND_ENGINE_2
-			destroy_op_array(op_array TSRMLS_CC);
+			destroy_op_array(compiler->new_php.op_array TSRMLS_CC);
 #else
-			destroy_op_array(op_array);
-#endif
-			efree(op_array);
+			destroy_op_array(compiler->new_php.op_array);
+#endif
+			efree(compiler->new_php.op_array);
+			compiler->new_php.op_array = NULL;
 			h = NULL;
 		}
@@ -2088,9 +2078,9 @@
 		zend_op_array *old_active_op_array = CG(active_op_array);
 		/* install it */
-		CG(active_op_array) = op_array;
+		CG(active_op_array) = compiler->new_php.op_array;
 		xc_sandbox_free(&sandbox, XC_Install TSRMLS_CC);
 		CG(active_op_array) = old_active_op_array;
 	}
-	return op_array;
+	return compiler->new_php.op_array;
 
 err_aftersandbox:
@@ -2098,10 +2088,10 @@
 	xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 
+	cache->compiling = 0;
 	if (catched) {
-		cache->compiling = 0;
 		cache->errors ++;
 		zend_bailout();
 	}
-	return op_array;
+	return compiler->new_php.op_array;
 }
 /* }}} */
@@ -2839,5 +2829,4 @@
 		else {
 			RETVAL_NULL();
-			cache->misses ++;
 		}
 	} LEAVE_LOCK(cache);
@@ -3025,4 +3014,5 @@
 				zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_entry_var->value);
 				Z_LVAL_P(zv) = value;
+				++cache->updates;
 				break; /* leave lock */
 			}
