From 811f20aaa5030035666d9f325dd7c64632c70a50 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 22 Oct 2018 14:10:49 +0300 Subject: [PATCH] Added information about preloading to opcache_get_status() --- ext/opcache/zend_accelerator_module.c | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 23a4b9316c5..b9d887918bd 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -662,6 +662,44 @@ static ZEND_FUNCTION(opcache_get_status) add_assoc_double(&statistics, "opcache_hit_rate", reqs?(((double) ZCSG(hits))/reqs)*100.0:0); add_assoc_zval(return_value, "opcache_statistics", &statistics); + if (ZCSG(preload_script)) { + array_init(&statistics); + + add_assoc_long(&statistics, "memory_consumption", ZCSG(preload_script)->dynamic_members.memory_consumption); + + if (zend_hash_num_elements(&ZCSG(preload_script)->script.function_table)) { + zend_op_array *op_array; + + array_init(&scripts); + ZEND_HASH_FOREACH_PTR(&ZCSG(preload_script)->script.function_table, op_array) { + add_next_index_str(&scripts, op_array->function_name); + } ZEND_HASH_FOREACH_END(); + add_assoc_zval(&statistics, "functions", &scripts); + } + + if (zend_hash_num_elements(&ZCSG(preload_script)->script.class_table)) { + zend_class_entry *ce; + + array_init(&scripts); + ZEND_HASH_FOREACH_PTR(&ZCSG(preload_script)->script.class_table, ce) { + add_next_index_str(&scripts, ce->name); + } ZEND_HASH_FOREACH_END(); + add_assoc_zval(&statistics, "classes", &scripts); + } + + if (ZCSG(saved_scripts)) { + zend_persistent_script **p = ZCSG(saved_scripts); + + array_init(&scripts); + while (*p) { + add_next_index_str(&scripts, (*p)->script.filename); + p++; + } + add_assoc_zval(&statistics, "scripts", &scripts); + } + add_assoc_zval(return_value, "preload_statistics", &statistics); + } + if (fetch_scripts) { /* accelerated scripts */ if (accelerator_get_scripts(&scripts)) {