/* {{{ proto array accelerator_get_scripts() Get the scripts which are accelerated by ZendAccelerator */ static zval* accelerator_get_scripts(TSRMLS_D) { uint i; zval *return_value,*persistent_script_report; zend_accel_hash_entry *cache_entry; struct tm *ta; struct timeval exec_time; struct timeval fetch_time; if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled) || accelerator_shm_read_lock(TSRMLS_C) != SUCCESS) { return 0; } MAKE_STD_ZVAL(return_value); array_init(return_value); for (i = 0; i<ZCSG(hash).max_num_entries; i++) { for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) { zend_persistent_script *script; char *str; size_t len; if (cache_entry->indirect) continue; script = (zend_persistent_script *)cache_entry->data; MAKE_STD_ZVAL(persistent_script_report); array_init(persistent_script_report); add_assoc_stringl(persistent_script_report, "full_path", script->full_path, script->full_path_len, 1); add_assoc_long(persistent_script_report, "hits", script->dynamic_members.hits); add_assoc_long(persistent_script_report, "memory_consumption", script->dynamic_members.memory_consumption); ta = localtime(&script->dynamic_members.last_used); str = asctime(ta); len = strlen(str); if (len > 0 && str[len - 1] == '\n') len--; add_assoc_stringl(persistent_script_report, "last_used", str, len, 1); add_assoc_long(persistent_script_report, "last_used_timestamp", script->dynamic_members.last_used); if (ZCG(accel_directives).validate_timestamps) { add_assoc_long(persistent_script_report, "timestamp", (long)script->timestamp); } timerclear(&exec_time); timerclear(&fetch_time); zend_hash_update(return_value->value.ht, cache_entry->key, cache_entry->key_length, &persistent_script_report, sizeof(zval *), NULL); } } accelerator_shm_read_unlock(TSRMLS_C); return return_value; }
/* {{{ proto array accelerator_get_scripts() Get the scripts which are accelerated by ZendAccelerator */ static int accelerator_get_scripts(zval *return_value) { uint32_t i; zval persistent_script_report; zend_accel_hash_entry *cache_entry; struct tm *ta; struct timeval exec_time; struct timeval fetch_time; if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { return 0; } array_init(return_value); for (i = 0; i<ZCSG(hash).max_num_entries; i++) { for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) { zend_persistent_script *script; char *str; size_t len; if (cache_entry->indirect) continue; script = (zend_persistent_script *)cache_entry->data; array_init(&persistent_script_report); add_assoc_str(&persistent_script_report, "full_path", zend_string_dup(script->script.filename, 0)); add_assoc_long(&persistent_script_report, "hits", (zend_long)script->dynamic_members.hits); add_assoc_long(&persistent_script_report, "memory_consumption", script->dynamic_members.memory_consumption); ta = localtime(&script->dynamic_members.last_used); str = asctime(ta); len = strlen(str); if (len > 0 && str[len - 1] == '\n') len--; add_assoc_stringl(&persistent_script_report, "last_used", str, len); add_assoc_long(&persistent_script_report, "last_used_timestamp", script->dynamic_members.last_used); if (ZCG(accel_directives).validate_timestamps) { add_assoc_long(&persistent_script_report, "timestamp", (zend_long)script->timestamp); } timerclear(&exec_time); timerclear(&fetch_time); zend_hash_str_update(Z_ARRVAL_P(return_value), cache_entry->key, cache_entry->key_length, &persistent_script_report); } } accelerator_shm_read_unlock(); return 1; }