summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2016-01-09 10:39:35 +0100
committerRemi Collet <fedora@famillecollet.com>2016-01-09 10:39:35 +0100
commit690a21552b58a9967cfcec480c651973de3fcfd8 (patch)
tree2b50ff89b5a575a026b48c193e9763e94a41dd25
parent78f56b8bcfcb38b900f7ba85eec00f11b7c0ec5a (diff)
php-pecl-apcu: 5.1.2-2, upstream patches for apcu_inc / apcu_dec
-rw-r--r--REFLECTION-PHP7177
-rw-r--r--apcu-pr.patch78
-rw-r--r--apcu-upstream.patch227
-rw-r--r--php-pecl-apcu-php7.spec12
4 files changed, 241 insertions, 253 deletions
diff --git a/REFLECTION-PHP7 b/REFLECTION-PHP7
index 9b0f981..91fafcd 100644
--- a/REFLECTION-PHP7
+++ b/REFLECTION-PHP7
@@ -1,4 +1,4 @@
-Extension [ <persistent> extension #70 apcu version 5.1.0 ] {
+Extension [ <persistent> extension #56 apcu version 5.1.2 ] {
- INI {
Entry [ apc.enabled <SYSTEM> ]
@@ -23,7 +23,7 @@ Extension [ <persistent> extension #70 apcu version 5.1.0 ] {
Current = '0'
}
Entry [ apc.mmap_file_mask <SYSTEM> ]
- Current = '/tmp/apc.PaEi1m'
+ Current = '/tmp/apc.FeiOLJ'
}
Entry [ apc.enable_cli <SYSTEM> ]
Current = '1'
@@ -49,7 +49,7 @@ Extension [ <persistent> extension #70 apcu version 5.1.0 ] {
}
- Constants [16] {
- Constant [ integer ] { 139697376948720 }
+ Constant [ integer ] { 140593052737952 }
Constant [ integer APC_LIST_ACTIVE ] { 1 }
Constant [ integer APC_LIST_DELETED ] { 2 }
Constant [ integer APC_ITER_TYPE ] { 1 }
@@ -243,174 +243,3 @@ Extension [ <persistent> extension #70 apcu version 5.1.0 ] {
}
}
-Extension [ <persistent> extension #71 apc version 5.1.0 ] {
-
- - Dependencies {
- Dependency [ apcu (Required) ]
- }
-
- - Functions {
- Function [ <internal:apc> function apc_cache_info ] {
-
- - Parameters [2] {
- Parameter #0 [ <required> $ignored ]
- Parameter #1 [ <optional> $limited ]
- }
- }
- Function [ <internal:apc> function apc_clear_cache ] {
-
- - Parameters [1] {
- Parameter #0 [ <required> $ignored ]
- }
- }
- Function [ <internal:apc> function apc_store ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <required> $var ]
- Parameter #2 [ <optional> $ttl ]
- }
- }
- Function [ <internal:apc> function apc_fetch ] {
-
- - Parameters [2] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <optional> &$success ]
- }
- }
- Function [ <internal:apc> function apc_enabled ] {
-
- - Parameters [0] {
- }
- }
- Function [ <internal:apc> function apc_delete ] {
-
- - Parameters [1] {
- Parameter #0 [ <required> $keys ]
- }
- }
- Function [ <internal:apc> function apc_add ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <required> $var ]
- Parameter #2 [ <optional> $ttl ]
- }
- }
- Function [ <internal:apc> function apc_sma_info ] {
-
- - Parameters [1] {
- Parameter #0 [ <optional> $limited ]
- }
- }
- Function [ <internal:apc> function apc_inc ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <optional> $step ]
- Parameter #2 [ <optional> &$success ]
- }
- }
- Function [ <internal:apc> function apc_dec ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <optional> $step ]
- Parameter #2 [ <optional> &$success ]
- }
- }
- Function [ <internal:apc> function apc_cas ] {
-
- - Parameters [3] {
- Parameter #0 [ <required> $key ]
- Parameter #1 [ <required> $old ]
- Parameter #2 [ <required> $new ]
- }
- }
- Function [ <internal:apc> function apc_exists ] {
-
- - Parameters [1] {
- Parameter #0 [ <required> $keys ]
- }
- }
- }
-
- - Classes [1] {
- Class [ <internal:apc> <iterateable> class APCIterator extends APCuIterator implements Traversable, Iterator ] {
-
- - Constants [0] {
- }
-
- - Static properties [0] {
- }
-
- - Static methods [0] {
- }
-
- - Properties [0] {
- }
-
- - Methods [9] {
- Method [ <internal:apc, overwrites APCuIterator, ctor> public method __construct ] {
-
- - Parameters [5] {
- Parameter #0 [ <required> $ignored ]
- Parameter #1 [ <optional> $search ]
- Parameter #2 [ <optional> $format ]
- Parameter #3 [ <optional> $chunk_size ]
- Parameter #4 [ <optional> $list ]
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator, prototype Iterator> public method rewind ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator, prototype Iterator> public method current ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator, prototype Iterator> public method key ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator, prototype Iterator> public method next ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator, prototype Iterator> public method valid ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator> public method getTotalHits ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator> public method getTotalSize ] {
-
- - Parameters [0] {
- }
- }
-
- Method [ <internal:apcu, inherits APCuIterator> public method getTotalCount ] {
-
- - Parameters [0] {
- }
- }
- }
- }
- }
-}
-
diff --git a/apcu-pr.patch b/apcu-pr.patch
deleted file mode 100644
index 434d9df..0000000
--- a/apcu-pr.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From 896b1643b4295a37fba4e0fb5cb8ffb3c10da851 Mon Sep 17 00:00:00 2001
-From: Remi Collet <fedora@famillecollet.com>
-Date: Tue, 9 Jun 2015 14:34:23 +0200
-Subject: [PATCH 1/2] use ['info'] instead of undefined ['key']
-
----
- apc.php | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
-diff --git a/apc.php b/apc.php
-index cedf096..119d74e 100644
---- a/apc.php
-+++ b/apc.php
-@@ -915,7 +915,6 @@ function block_sort($array1, $array2)
- }
- $fieldname='info';
- $fieldheading='User Entry Label';
-- $fieldkey='key';
-
- $cols=6;
- echo <<<EOB
-@@ -1041,7 +1040,7 @@ function block_sort($array1, $array2)
- } else if ($MYREQUEST['OB'] == OB_USER_CACHE) {
-
- echo '<td class="td-last center">';
-- echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldkey]), '">Delete Now</a>]';
-+ echo '[<a href="', $MY_SELF, '&OB=', $MYREQUEST['OB'], '&DU=', urlencode($entry[$fieldname]), '">Delete Now</a>]';
- echo '</td>';
- } else {
- echo '<td class="td-last center"> &nbsp; </td>';
-
-From 20c53f1ee86a659d5316977096efe5edf03eb958 Mon Sep 17 00:00:00 2001
-From: Remi Collet <fedora@famillecollet.com>
-Date: Tue, 9 Jun 2015 14:36:25 +0200
-Subject: [PATCH 2/2] silent the fetch, to hide "Warning: Class
- __PHP_Incomplete_Class has no unserializer in..."
-
----
- apc.php | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/apc.php b/apc.php
-index 119d74e..47debee 100644
---- a/apc.php
-+++ b/apc.php
-@@ -1048,7 +1048,7 @@ function block_sort($array1, $array2)
- echo '</tr>';
- if ($sh == $MYREQUEST["SH"]) {
- echo '<tr>';
-- echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['info']), 1)).'</pre></td>';
-+ echo '<td colspan="7"><pre>'.htmlentities(print_r(@apcu_fetch($entry['info']), 1)).'</pre></td>';
- echo '</tr>';
- }
- $i++;
-From f095923ecaa46a6e3c64bee913cf527077393539 Mon Sep 17 00:00:00 2001
-From: Stanislav Khromov <stanislav.khromov+github@gmail.com>
-Date: Fri, 17 Oct 2014 15:44:20 +0200
-Subject: [PATCH] Scroll to cache entry when clicking on it
-
----
- apc.php | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/apc.php b/apc.php
-index efc7eec..cedf096 100644
---- a/apc.php
-+++ b/apc.php
-@@ -1020,8 +1020,8 @@ function block_sort($array1, $array2)
- $sh=md5($entry["info"]);
- $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8');
- echo
-- '<tr class=tr-',$i%2,'>',
-- "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"\">",$field_value,'</a></td>',
-+ '<tr id="key-'. $sh .'" class=tr-',$i%2,'>',
-+ "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"#key-". $sh ."\">",$field_value,'</a></td>',
- '<td class="td-n center">',$entry['num_hits'],'</td>',
- '<td class="td-n right">',$entry['mem_size'],'</td>',
- '<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>',
diff --git a/apcu-upstream.patch b/apcu-upstream.patch
new file mode 100644
index 0000000..b21aeb6
--- /dev/null
+++ b/apcu-upstream.patch
@@ -0,0 +1,227 @@
+diff --git a/apc_globals.h b/apc_globals.h
+index 40509f0..a0de234 100644
+--- a/apc_globals.h
++++ b/apc_globals.h
+@@ -41,12 +41,12 @@
+ ZEND_BEGIN_MODULE_GLOBALS(apcu)
+ /* configuration parameters */
+ zend_bool enabled; /* if true, apc is enabled (defaults to true) */
+- long shm_segments; /* number of shared memory segments to use */
+- long shm_size; /* size of each shared memory segment (in MB) */
+- long entries_hint; /* hint at the number of entries expected */
+- long gc_ttl; /* parameter to apc_cache_create */
+- long ttl; /* parameter to apc_cache_create */
+- long smart; /* smart value */
++ zend_long shm_segments; /* number of shared memory segments to use */
++ zend_long shm_size; /* size of each shared memory segment (in MB) */
++ zend_long entries_hint; /* hint at the number of entries expected */
++ zend_long gc_ttl; /* parameter to apc_cache_create */
++ zend_long ttl; /* parameter to apc_cache_create */
++ zend_long smart; /* smart value */
+
+ #if APC_MMAP
+ char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */
+diff --git a/php_apc.c b/php_apc.c
+index c35ede1..83fd758 100644
+--- a/php_apc.c
++++ b/php_apc.c
+@@ -118,11 +118,11 @@ static PHP_INI_MH(OnUpdateShmSize) /* {{{ */
+ return FAILURE;
+ }
+
+- if (s < 1048576L) {
++ if (s < Z_L(1048576)) {
+ /* if it's less than 1Mb, they are probably using the old syntax */
+ php_error_docref(
+ NULL, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files");
+- s = s * 1048576L;
++ s = s * Z_L(1048576);
+ }
+
+ APCG(shm_size) = s;
+@@ -526,60 +526,46 @@ PHP_FUNCTION(apcu_add) {
+ /* {{{ php_inc_updater */
+
+ struct php_inc_updater_args {
+- zend_long step;
+- zend_long lval;
++ zval step;
++ zval rval;
+ };
+
+ static zend_bool php_inc_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) {
+ struct php_inc_updater_args *args = (struct php_inc_updater_args*) data;
+
+ if (Z_TYPE(entry->val) == IS_LONG) {
+- while (args->step--) {
+- fast_long_increment_function(&entry->val);
+- }
+- args->lval = Z_LVAL(entry->val);
++ fast_long_add_function(&entry->val, &entry->val, &args->step);
++ ZVAL_COPY_VALUE(&args->rval, &entry->val);
+ return 1;
+ }
+
+ return 0;
+ }
+
+-static zend_bool php_dec_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) {
+- struct php_inc_updater_args *args = (struct php_inc_updater_args*) data;
+-
+- if (Z_TYPE(entry->val) == IS_LONG) {
+- while (args->step--) {
+- fast_long_decrement_function(&entry->val);
+- }
+- args->lval = Z_LVAL(entry->val);
+- return 1;
+- }
+-
+- return 0;
+-}
+-/* }}} */
+-
+ /* {{{ proto long apc_inc(string key [, long step [, bool& success]])
+ */
+ PHP_FUNCTION(apcu_inc) {
+ zend_string *key;
+- struct php_inc_updater_args args = {1L, -1};
++ struct php_inc_updater_args args;
++ zend_long step = 1;
+ zval *success = NULL;
+
+- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) {
+ return;
+ }
+-
++
+ if (success) {
+ ZVAL_DEREF(success);
+ zval_ptr_dtor(success);
+ }
+
++ ZVAL_LONG(&args.step, step);
++
+ if (php_apc_update(key, php_inc_updater, &args)) {
+ if (success) {
+ ZVAL_TRUE(success);
+ }
+- RETURN_LONG(args.lval);
++ RETURN_ZVAL(&args.rval, 0, 0);
+ }
+
+ if (success) {
+@@ -594,24 +580,27 @@ PHP_FUNCTION(apcu_inc) {
+ */
+ PHP_FUNCTION(apcu_dec) {
+ zend_string *key;
+- struct php_inc_updater_args args = {1L, -1};
++ struct php_inc_updater_args args;
++ zend_long step = 1;
+ zval *success = NULL;
+
+- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) {
+ return;
+ }
+-
++
+ if (success) {
+ ZVAL_DEREF(success);
+ zval_ptr_dtor(success);
+ }
+
+- if (php_apc_update(key, php_dec_updater, &args)) {
++ ZVAL_LONG(&args.step, 0 - step);
++
++ if (php_apc_update(key, php_inc_updater, &args)) {
+ if (success) {
+ ZVAL_TRUE(success);
+ }
+
+- RETURN_LONG(args.lval);
++ RETURN_ZVAL(&args.rval, 0, 0);
+ }
+
+ if (success) {
+@@ -662,9 +651,7 @@ PHP_FUNCTION(apcu_cas) {
+ PHP_FUNCTION(apcu_fetch) {
+ zval *key;
+ zval *success = NULL;
+- apc_cache_entry_t* entry;
+ time_t t;
+- apc_context_t ctxt = {0,};
+
+ if (!APCG(enabled)) {
+ RETURN_FALSE;
+diff --git a/tests/apc_012.phpt b/tests/apc_012.phpt
+index e7844ef..0d3b050 100644
+--- a/tests/apc_012.phpt
++++ b/tests/apc_012.phpt
+@@ -10,25 +10,28 @@ apc.enable_cli=1
+ $key="testkey";
+ $i=PHP_INT_MAX;
+ apcu_store($key, $i);
+-$j=apcu_fetch($key);
++var_dump($j=apcu_fetch($key));
+ var_dump($i==$j);
+
+ apcu_inc($key, 1);
+ $i++;
+-$j=apcu_fetch($key);
++var_dump($j=apcu_fetch($key));
+ var_dump($i==$j);
+
+ $i=PHP_INT_MIN;
+ apcu_store($key, $i);
+ apcu_dec($key, 1);
+ $i--;
+-$j=apcu_fetch($key);
++var_dump($j=apcu_fetch($key));
+ var_dump($i==$j);
+ ?>
+ ===DONE===
+ <?php exit(0); ?>
+---EXPECT--
++--EXPECTF--
++int(%d)
+ bool(true)
++float(%s)
+ bool(true)
++float(%s)
+ bool(true)
+ ===DONE===
+diff --git a/tests/apc_inc_perf.phpt b/tests/apc_inc_perf.phpt
+new file mode 100644
+index 0000000..8f082f1
+--- /dev/null
++++ b/tests/apc_inc_perf.phpt
+@@ -0,0 +1,28 @@
++--TEST--
++APC: apcu_inc/apcu_dec performance test (gh#164)
++--SKIPIF--
++<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
++--INI--
++apc.enabled=1
++apc.enable_cli=1
++apc.file_update_protection=0
++--FILE--
++<?php
++apcu_store('foobar', 1);
++$t = microtime(true);
++var_dump(apcu_inc('foobar', 0x76543210));
++var_dump(apcu_dec('foobar', 0x76543210));
++var_dump(apcu_dec('foobar', -999999999));
++var_dump(apcu_inc('foobar', -999999999));
++$t = microtime(true) - $t;
++var_dump($t < 0.1 ? true : $t);
++?>
++===DONE===
++<?php exit(0); ?>
++--EXPECTF--
++int(1985229329)
++int(1)
++int(1000000000)
++int(1)
++bool(true)
++===DONE===
diff --git a/php-pecl-apcu-php7.spec b/php-pecl-apcu-php7.spec
index 7f988ac..0a9b2ab 100644
--- a/php-pecl-apcu-php7.spec
+++ b/php-pecl-apcu-php7.spec
@@ -41,13 +41,16 @@ Version: 5.1.2
Release: 0.2.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz
%else
-Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
%endif
Source1: %{pecl_name}-5.1.2.ini
Source2: %{pecl_name}-panel.conf
Source3: %{pecl_name}.conf.php
+# Patch from master, for apcu_in / apcu_dec issues
+Patch1: %{pecl_name}-upstream.patch
+
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/APCu
@@ -154,6 +157,8 @@ mv %{pecl_name}-%{version} NTS
%endif
cd NTS
+%patch1 -p1 -b .upstream
+
# Sanity check, really often broken
extver=$(sed -n '/#define PHP_APCU_VERSION/{s/.* "//;s/".*$//;p}' php_apc.h)
if test "x${extver}" != "x%{version}%{?prever}%{?gh_date:dev}"; then
@@ -321,6 +326,11 @@ fi
%changelog
+* Sat Jan 9 2016 Remi Collet <remi@fedoraproject.org> - 5.1.2-2
+- add upstream patches to fix issues with apcu_inc / apcu_dec
+ https://github.com/krakjoe/apcu/issues/158 - negative step hangs
+ https://github.com/krakjoe/apcu/issues/164 - huge step performance
+
* Mon Dec 7 2015 Remi Collet <remi@fedoraproject.org> - 5.1.2-1
- Update to 5.1.2 (stable)