Browse Source

merged r585:592 from trunk

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.3@627 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.3
Xuefer 12 years ago
parent
commit
22aaf97d2e
  1. 5
      Makefile.frag
  2. 4
      admin/config.php.example
  3. 22
      admin/edit.php
  4. 2
      admin/edit.tpl.php
  5. 24
      run-xcachetest
  6. 16
      utils.c
  7. 3
      utils.h
  8. 2
      xcache-test.ini
  9. 26
      xcache.c
  10. 3
      xcache_globals.h

5
Makefile.frag

@ -14,7 +14,7 @@ $(XCACHE_STRUCTINFO_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/mkstructinfo.awk
-$(XCACHE_AWK) -f $(srcdir)/mkstructinfo.awk < $(XCACHE_INCLUDES_I) > $(XCACHE_STRUCTINFO_OUT).tmp && mv -f $(XCACHE_STRUCTINFO_OUT).tmp $(XCACHE_STRUCTINFO_OUT)
$(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SOURCES)
$(M4) -D srcdir="$(srcdir)" -D builddir="$(builddir)" $(XCACHE_ENABLE_TEST) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
$(M4) -D srcdir='`'"$(srcdir)'" -D builddir='`'"$(builddir)'" $(XCACHE_ENABLE_TEST) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
mv -f $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT)
$(XCACHE_PROC_H): $(XCACHE_PROC_OUT)
@ -38,6 +38,7 @@ xcachesvnclean: clean
cat $(srcdir)/.cvsignore | grep -v ^Makefile | grep -v ^config.nice | xargs rm -rf
xcachetest:
$(SED) "s#\\./modules/#$(top_builddir)/modules/#" < $(srcdir)/xcache-test.ini > $(top_builddir)/tmp-php.ini
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(srcdir)/run-xcachetest -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php $(TESTS) $(TEST_ARGS) -c $(srcdir)/xcache-test.ini
$(srcdir)/run-xcachetest -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php $(TESTS) $(TEST_ARGS) -c $(top_builddir)/tmp-php.ini

4
admin/config.php.example

@ -16,6 +16,10 @@ $usage_graph_width = 120;
// do not define both with
// $free_graph_width = 120;
// only enable if you have password protection for admin page
// enabling this option will cause user to eval() whatever code they want
$enable_eval = false;
// this function is detected by xcache.tpl.php, and enabled if function_exists
// this ob filter is applied for the cache list, not the whole page
function ob_filter_path_nicer($o)

22
admin/edit.php

@ -11,12 +11,30 @@ $name = $_GET['name'];
$vcnt = xcache_count(XC_TYPE_VAR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
eval('$value = ' . $_POST['value']);
if ($enable_eval) {
eval('$value = ' . $_POST['value']);
}
else {
$value = $_POST['value'];
}
xcache_set($name, $value);
header("Location: xcache.php?type=" . XC_TYPE_VAR);
exit;
}
$value = var_export(xcache_get($name), true);
$value = xcache_get($name);
if ($enable_eval) {
$value = var_export($value, true);
$editable = true;
}
else {
if (is_string($value)) {
$editable = true;
}
else {
$editable = false;
$value = var_export($value, true);
}
}
$xcache_version = XCACHE_VERSION;
$xcache_modules = XCACHE_MODULES;

2
admin/edit.tpl.php

@ -6,7 +6,7 @@ $h_value = htmlspecialchars($value);
<form method="post" action="">
<fieldset>
<legend><?php echo sprintf(_T("Editing Variable %s"), $h_name); ?></legend>
<textarea name="value" style="width: 100%; height: 200px; overflow-y: auto"><?php echo $h_value; ?></textarea><br>
<textarea name="value" style="width: 100%; height: 200px; overflow-y: auto" <?php echo $editable ? "" : "disabled=disabled"; ?>><?php echo $h_value; ?></textarea><br>
<input type="submit">
</fieldset>
</form>

24
run-xcachetest

@ -1,8 +1,12 @@
#!/bin/sh
getAbsolutePath() {
which readlink >/dev/null 2>&1 && readlink -f "$@" || echo "$@"
}
# use symlink first
if test -x ./php-cli ; then
php_cli=./php-cli
php_cli=`getAbsolutePath ./php-cli`
elif test ! -z "$TEST_PHP_EXECUTABLE" && test -x "$TEST_PHP_EXECUTABLE"; then
php_cli="$TEST_PHP_EXECUTABLE"
else
@ -10,31 +14,23 @@ else
fi
if test -x ./php-cgi ; then
php_cgi=./php-cgi
php_cgi=`getAbsolutePath ./php-cgi`
else
php_cgi="`which php-cgi`"
fi
test -z "$PHP_SRC" && PHP_SRC=./php-src
if test -z "$TEST_PHP_USER" ; then
TEST_PHP_USER="$PHP_SRC/tests"
for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ext/spl/tests; do
if test -d "$PHP_SRC/$i" ; then
TEST_PHP_USER="$TEST_PHP_USER,$PHP_SRC/$i"
fi
done
fi
test -z "$PHP_SRC" && PHP_SRC=`getAbsolutePath ./php-src`
TEST_PHP_EXECUTABLE="$php_cli"
TEST_PHP_CGI_EXECUTABLE="$php_cgi"
TEST_PHP_SRCDIR="$PHP_SRC"
export TEST_PHP_CGI_EXECUTABLE
export TEST_PHP_EXECUTABLE
export TEST_PHP_USER
export TEST_PHP_CGI_EXECUTABLE
export TEST_PHP_SRCDIR
echo "XCache test running with:"
echo "TEST_PHP_CGI_EXECUTABLE: $TEST_PHP_CGI_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE: $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_USER: $TEST_PHP_USER"
exec "$php_cli" "$@"

16
utils.c

@ -597,6 +597,14 @@ static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */
/* }}} */
#endif
static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
{
c->name = zend_strndup(c->name, c->name_len - 1);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
}
/* }}} */
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
{
HashTable *h;
@ -634,6 +642,10 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
#ifdef HAVE_XCACHE_CONSTANT
h = OG(zend_constants);
zend_hash_init_ex(&TG(zend_constants), 20, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
{
zend_constant tmp_const;
zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const));
}
#endif
h = OG(function_table);
zend_hash_init_ex(&TG(function_table), 128, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
@ -676,7 +688,7 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
sandbox->orig_compiler_options = CG(compiler_options);
/* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK
*/
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_DELAYED_BINDING;
CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION | ZEND_COMPILE_DELAYED_BINDING;
#endif
XG(sandbox) = (void *) sandbox;
@ -695,7 +707,7 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t instal
Bucket *b;
#ifdef HAVE_XCACHE_CONSTANT
b = TG(zend_constants).pListHead;
b = /*TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext :*/ TG(zend_constants).pListHead;
/* install constants */
while (b != NULL) {
zend_constant *c = (zend_constant*) b->pData;

3
utils.h

@ -94,6 +94,9 @@ typedef struct {
HashTable tmp_function_table;
HashTable tmp_class_table;
HashTable tmp_auto_globals;
#ifdef HAVE_XCACHE_CONSTANT
Bucket *tmp_internal_constant_tail;
#endif
Bucket *tmp_internal_function_tail;
Bucket *tmp_internal_class_tail;

2
xcache-test.ini

@ -7,7 +7,7 @@ zend_extension_ts=./modules/xcache.so
zend_extension=./modules/xcache.so
xcache.cacher = On
xcache.test=1
xcache.size = 1M
xcache.size = 16M
xcache.count = 1
xcache.var_size = 1M
xcache.var_count = 1

26
xcache.c

@ -1593,20 +1593,40 @@ err:
return 0;
}
/* }}} */
static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
{
c->name = zend_strndup(c->name, c->name_len - 1);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
}
/* }}} */
static void xc_request_init(TSRMLS_D) /* {{{ */
{
int i;
if (!XG(internal_table_copied)) {
#ifdef HAVE_XCACHE_CONSTANT
zend_constant tmp_const;
#endif
zend_function tmp_func;
xc_cest_t tmp_cest;
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_destroy(&XG(internal_constant_table));
#endif
zend_hash_destroy(&XG(internal_function_table));
zend_hash_destroy(&XG(internal_class_table));
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_init_ex(&XG(internal_constant_table), 20, NULL, NULL, 1, 0);
#endif
zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
zend_hash_init_ex(&XG(internal_class_table), 10, NULL, NULL, 1, 0);
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const));
#endif
zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
@ -1665,6 +1685,9 @@ void xc_init_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
{
memset(xcache_globals, 0, sizeof(zend_xcache_globals));
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0);
#endif
zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
zend_hash_init_ex(&xcache_globals->internal_class_table, 1, NULL, NULL, 1, 0);
}
@ -1696,6 +1719,9 @@ void xc_shutdown_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
}
if (xcache_globals->internal_table_copied) {
#ifdef HAVE_XCACHE_CONSTANT
zend_hash_destroy(&xcache_globals->internal_constant_table);
#endif
zend_hash_destroy(&xcache_globals->internal_function_table);
zend_hash_destroy(&xcache_globals->internal_class_table);
}

3
xcache_globals.h

@ -21,6 +21,9 @@ ZEND_BEGIN_MODULE_GLOBALS(xcache)
HashTable gc_op_arrays;
#endif
#ifdef HAVE_XCACHE_CONSTANT
HashTable internal_constant_table;
#endif
HashTable internal_function_table;
HashTable internal_class_table;
zend_bool internal_table_copied;

Loading…
Cancel
Save