Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 466)
+++ /trunk/xcache.c	(revision 467)
@@ -1651,9 +1651,10 @@
 
 err:
-	xc_destroy();
 	if (xc_php_caches || xc_var_caches) {
+		xc_destroy();
 		/* shm destroied in xc_destroy() */
 	}
 	else if (shm) {
+		xc_destroy();
 		xc_shm_destroy(shm);
 	}
