From de410a5cea96d3f106e021b2d41ca4c202787f11 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 8 Apr 2013 10:38:14 +0200 Subject: php-pecl-memcache: 3.0.8 --- LICENSE | 68 ------------------- connect.inc | 97 +++++++++++++++++++++++++++ php-pecl-memcache-3.0.5-get-mem-corrupt.patch | 89 ------------------------ php-pecl-memcache-3.0.7-bug59602.patch | 13 ---- php-pecl-memcache-3.0.7-get-mem-corrupt.patch | 88 ------------------------ php-pecl-memcache.spec | 58 +++++++++++----- 6 files changed, 138 insertions(+), 275 deletions(-) delete mode 100644 LICENSE create mode 100644 connect.inc delete mode 100644 php-pecl-memcache-3.0.5-get-mem-corrupt.patch delete mode 100644 php-pecl-memcache-3.0.7-bug59602.patch delete mode 100644 php-pecl-memcache-3.0.7-get-mem-corrupt.patch diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 6c1c170..0000000 --- a/LICENSE +++ /dev/null @@ -1,68 +0,0 @@ --------------------------------------------------------------------- - The PHP License, version 3.0 -Copyright (c) 1999 - 2006 The PHP Group. All rights reserved. --------------------------------------------------------------------- - -Redistribution and use in source and binary forms, with or without -modification, is permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The name "PHP" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact group@php.net. - - 4. Products derived from this software may not be called "PHP", nor - may "PHP" appear in their name, without prior written permission - from group@php.net. You may indicate that your software works in - conjunction with PHP by saying "Foo for PHP" instead of calling - it "PHP Foo" or "phpfoo" - - 5. The PHP Group may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. - Once covered code has been published under a particular version - of the license, you may always continue to use it under the terms - of that version. You may also choose to use such covered code - under the terms of any subsequent version of the license - published by the PHP Group. No one other than the PHP Group has - the right to modify the terms applicable to covered code created - under this License. - - 6. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes PHP, freely available from - ". - -THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND -ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP -DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------- - -This software consists of voluntary contributions made by many -individuals on behalf of the PHP Group. - -The PHP Group can be contacted via Email at group@php.net. - -For more information on the PHP Group and the PHP project, -please see . - -This product includes the Zend Engine, freely available at -. diff --git a/connect.inc b/connect.inc new file mode 100644 index 0000000..96d2875 --- /dev/null +++ b/connect.inc @@ -0,0 +1,97 @@ + array( + 'crc32' => array('key1_abc', 'key2_abcde'), + 'fnv' => array('key1_a', 'key2_2534534'), + ), + 'standard' => array( + 'crc32' => array('load_test_key1', 'load_test_key2'), + 'fnv' => array('key1_ab', 'key2_a'), + ), + ); + +$strat = strtolower(ini_get('memcache.hash_strategy')); +$func = strtolower(ini_get('memcache.hash_function')); +list ($balanceKey1, $balanceKey2) = $balanceKeys[$strat][$func]; + +if (!isset($udpPort)) + $udpPort = 0; +if (!isset($udpPort2)) + $udpPort2 = 0; + +$memcache = memcache_connect($host, $port); + +function test_connect1() { + global $host, $port, $udpPort; + $memcache = new MemcachePool(); + $memcache->connect($host, $port, isset($udpPort) ? $udpPort : 0); + return $memcache; +} + +function test_connect2() { + global $host2, $port2, $udpPort2; + $memcache = new MemcachePool(); + $memcache->connect($host2, $port2, isset($udpPort2) ? $udpPort2 : 0); + return $memcache; +} + +function test_connect_pool() { + global $host, $port, $udpPort, $host2, $port2, $udpPort2; + $memcache = new MemcachePool(); + $memcache->addServer($host, $port, isset($udpPort) ? $udpPort : 0); + $memcache->addServer($host2, $port2, isset($udpPort2) ? $udpPort2 : 0); + return $memcache; +} + +if (!$memcache) { + die('skip Connection to memcached failed'); +} + +?> diff --git a/php-pecl-memcache-3.0.5-get-mem-corrupt.patch b/php-pecl-memcache-3.0.5-get-mem-corrupt.patch deleted file mode 100644 index 0b7c66c..0000000 --- a/php-pecl-memcache-3.0.5-get-mem-corrupt.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 6e09e8db8d36de6a5020f5d517f62a8c16af8222 Mon Sep 17 00:00:00 2001 -From: "Vojtech Vitek (V-Teq)" -Date: Mon, 17 Oct 2011 16:17:51 +0200 -Subject: [PATCH] fix get/unserialize memory corruption - -Possible memory corruption (and segfault) after unserialising objects: -obj = $obj; -$memcache = new Memcache; -$memcache->connect('127.0.0.1', 11211); -$memcache->set('x', $obj, false, 300); -$x = $memcache->get('x'); -$x = $memcache->get('x'); -$x = $memcache->get('x'); -$x = $memcache->get('x'); -$x = $memcache->get('x'); - -Patch by Paul Clifford. - ---- - memcache-3.0.5/memcache_pool.c | 15 +++++++-------- - 1 files changed, 7 insertions(+), 8 deletions(-) - -diff --git memcache-3.0.5/memcache_pool.c memcache-3.0.5/memcache_pool.c -index 420a773..e89ebce 100644 ---- memcache-3.0.5/memcache_pool.c -+++ memcache-3.0.5/memcache_pool.c -@@ -422,8 +422,8 @@ int mmc_unpack_value( - char *data = NULL; - unsigned long data_len; - -- zval value; -- INIT_ZVAL(value); -+ zval *object; -+ ALLOC_INIT_ZVAL(object); - - if (flags & MMC_COMPRESSED) { - if (mmc_uncompress(buffer->value.c, bytes, &data, &data_len) != MMC_OK) { -@@ -439,7 +439,6 @@ int mmc_unpack_value( - if (flags & MMC_SERIALIZED) { - php_unserialize_data_t var_hash; - const unsigned char *p = (unsigned char *)data; -- zval *object = &value; - - char key_tmp[MMC_MAX_KEY_LEN + 1]; - mmc_request_value_handler value_handler; -@@ -495,7 +494,7 @@ int mmc_unpack_value( - long val; - data[data_len] = '\0'; - val = strtol(data, NULL, 10); -- ZVAL_LONG(&value, val); -+ ZVAL_LONG(object, val); - break; - } - -@@ -503,17 +502,17 @@ int mmc_unpack_value( - double val = 0; - data[data_len] = '\0'; - sscanf(data, "%lg", &val); -- ZVAL_DOUBLE(&value, val); -+ ZVAL_DOUBLE(object, val); - break; - } - - case MMC_TYPE_BOOL: -- ZVAL_BOOL(&value, data_len == 1 && data[0] == '1'); -+ ZVAL_BOOL(object, data_len == 1 && data[0] == '1'); - break; - - default: - data[data_len] = '\0'; -- ZVAL_STRINGL(&value, data, data_len, 0); -+ ZVAL_STRINGL(object, data, data_len, 0); - - if (!(flags & MMC_COMPRESSED)) { - /* release buffer because it's now owned by the zval */ -@@ -522,7 +521,7 @@ int mmc_unpack_value( - } - - /* delegate to value handler */ -- return request->value_handler(key, key_len, &value, flags, cas, request->value_handler_param TSRMLS_CC); -+ return request->value_handler(key, key_len, object, flags, cas, request->value_handler_param TSRMLS_CC); - } - } - /* }}}*/ --- -1.7.6.2 - diff --git a/php-pecl-memcache-3.0.7-bug59602.patch b/php-pecl-memcache-3.0.7-bug59602.patch deleted file mode 100644 index fd28fb3..0000000 --- a/php-pecl-memcache-3.0.7-bug59602.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- pecl/memcache/branches/NON_BLOCKING_IO/memcache.c 2012/10/31 08:49:59 328201 -+++ pecl/memcache/branches/NON_BLOCKING_IO/memcache.c 2012/10/31 12:27:09 328202 -@@ -1836,7 +1836,9 @@ - request = mmc_pool_request(pool, MMC_PROTO_TCP, mmc_stats_handler, stats, NULL, NULL TSRMLS_CC); - pool->protocol->stats(request, type, slabid, limit); - -- mmc_pool_schedule(pool, pool->servers[i], request TSRMLS_CC); -+ if (mmc_pool_schedule(pool, pool->servers[i], request TSRMLS_CC) == MMC_OK) { -+ mmc_pool_run(pool TSRMLS_CC); -+ } - } - - /* execute all requests */ diff --git a/php-pecl-memcache-3.0.7-get-mem-corrupt.patch b/php-pecl-memcache-3.0.7-get-mem-corrupt.patch deleted file mode 100644 index 109d38e..0000000 --- a/php-pecl-memcache-3.0.7-get-mem-corrupt.patch +++ /dev/null @@ -1,88 +0,0 @@ ---- pecl/memcache/branches/NON_BLOCKING_IO/memcache_pool.c 2012/09/23 07:13:18 327753 -+++ pecl/memcache/branches/NON_BLOCKING_IO/memcache_pool.c 2012/09/23 08:29:10 327754 -@@ -426,13 +426,15 @@ - { - char *data = NULL; - unsigned long data_len; -+ int rv; - -- zval value; -- INIT_ZVAL(value); -+ zval *object; -+ ALLOC_INIT_ZVAL(object); - - if (flags & MMC_COMPRESSED) { - if (mmc_uncompress(buffer->value.c, bytes, &data, &data_len) != MMC_OK) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to uncompress data"); -+ zval_ptr_dtor(&object); - return MMC_REQUEST_DONE; - } - } -@@ -444,7 +446,6 @@ - if (flags & MMC_SERIALIZED) { - php_unserialize_data_t var_hash; - const unsigned char *p = (unsigned char *)data; -- zval *object = &value; - - char key_tmp[MMC_MAX_KEY_LEN + 1]; - mmc_request_value_handler value_handler; -@@ -476,6 +477,7 @@ - } - - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to unserialize data"); -+ zval_ptr_dtor(&object); - return MMC_REQUEST_DONE; - } - -@@ -492,7 +494,9 @@ - } - - /* delegate to value handler */ -- return value_handler(key_tmp, key_len, object, flags, cas, value_handler_param TSRMLS_CC); -+ rv = value_handler(key_tmp, key_len, object, flags, cas, value_handler_param TSRMLS_CC); -+ zval_ptr_dtor(&object); -+ return rv; - } - else { - switch (flags & 0x0f00) { -@@ -500,7 +504,7 @@ - long val; - data[data_len] = '\0'; - val = strtol(data, NULL, 10); -- ZVAL_LONG(&value, val); -+ ZVAL_LONG(object, val); - break; - } - -@@ -508,17 +512,17 @@ - double val = 0; - data[data_len] = '\0'; - sscanf(data, "%lg", &val); -- ZVAL_DOUBLE(&value, val); -+ ZVAL_DOUBLE(object, val); - break; - } - - case MMC_TYPE_BOOL: -- ZVAL_BOOL(&value, data_len == 1 && data[0] == '1'); -+ ZVAL_BOOL(object, data_len == 1 && data[0] == '1'); - break; - - default: - data[data_len] = '\0'; -- ZVAL_STRINGL(&value, data, data_len, 0); -+ ZVAL_STRINGL(object, data, data_len, 0); - - if (!(flags & MMC_COMPRESSED)) { - /* release buffer because it's now owned by the zval */ -@@ -527,7 +531,9 @@ - } - - /* delegate to value handler */ -- return request->value_handler(key, key_len, &value, flags, cas, request->value_handler_param TSRMLS_CC); -+ rv = request->value_handler(key, key_len, object, flags, cas, request->value_handler_param TSRMLS_CC); -+ zval_ptr_dtor(&object); -+ return rv; - } - } - /* }}}*/ diff --git a/php-pecl-memcache.spec b/php-pecl-memcache.spec index 943d2e9..a38798f 100644 --- a/php-pecl-memcache.spec +++ b/php-pecl-memcache.spec @@ -1,32 +1,30 @@ %{!?__pecl: %{expand: %%global __pecl %{_bindir}/pecl}} %global pecl_name memcache +# Not ready, some failed UDP tests. Neded investigation. +%global with_tests %{?_with_tests:1}%{!?_with_tests:0} Summary: Extension to work with the Memcached caching daemon Name: php-pecl-memcache -Version: 3.0.7 -Release: 5%{?dist}.2 +Version: 3.0.8 +Release: 1%{?dist}.1 License: PHP Group: Development/Languages URL: http://pecl.php.net/package/%{pecl_name} Source: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz Source2: xml2changelog -# https://bugs.php.net/63141 -Source3: LICENSE - -# https://bugs.php.net/63142 -# http://svn.php.net/viewvc?view=revision&revision=327754 -Patch1: %{name}-3.0.5-get-mem-corrupt.patch - -# https://bugs.php.net/59602 -# http://svn.php.net/viewvc?view=revision&revision=328202 -Patch2: %{name}-3.0.7-bug59602.patch +# Missing in official archive +# http://svn.php.net/viewvc/pecl/memcache/branches/NON_BLOCKING_IO/tests/connect.inc?view=co +Source3: connect.inc BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: php-devel BuildRequires: php-pear BuildRequires: zlib-devel +%if %{with_tests} +BuildRequires: memcached +%endif Requires(post): %{__pecl} Requires(postun): %{__pecl} @@ -68,8 +66,6 @@ Memcache can be used as a PHP session handler. %setup -c -q pushd %{pecl_name}-%{version} -%patch1 -p1 -b .get-mem-corrupt.patch -%patch2 -p4 -b .bug54602 # Chech version as upstream often forget to update this extver=$(sed -n '/#define PHP_MEMCACHE_VERSION/{s/.* "//;s/".*$//;p}' php_memcache.h) @@ -82,8 +78,6 @@ popd %{__php} %{SOURCE2} package.xml | tee CHANGELOG | head -n 5 -cp -p %{SOURCE3} . - cat >%{pecl_name}.ini << 'EOF' ; ----- Enable %{pecl_name} extension module extension=%{pecl_name}.so @@ -170,6 +164,33 @@ install -Dpm 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml --define extension=%{pecl_name}.so \ --modules | grep %{pecl_name} +%if %{with_tests} +cd %{pecl_name}-%{version} +cp %{SOURCE3} tests +sed -e "s:/var/run/memcached/memcached.sock:$PWD/memcached.sock:" \ + -i tests/connect.inc + +# Launch the daemons +memcached -p 11211 -U 11211 -d -P $PWD/memcached1.pid +memcached -p 11212 -U 11212 -d -P $PWD/memcached2.pid +memcached -s $PWD/memcached.sock -d -P $PWD/memcached3.pid + +# Run the test Suite +ret=0 +TEST_PHP_EXECUTABLE=%{_bindir}/php \ +TEST_PHP_ARGS="-n -d extension_dir=$PWD/modules -d extension=%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{_bindir}/php -n run-tests.php || ret=1 + +# Cleanup +if [ -f memcached2.pid ]; then + kill $(cat memcached?.pid) +fi + +exit $ret +%endif + %clean rm -rf %{buildroot} @@ -187,7 +208,7 @@ fi %files %defattr(-, root, root, -) -%doc CHANGELOG %{pecl_name}-%{version}/CREDITS %{pecl_name}-%{version}/README LICENSE +%doc CHANGELOG %{pecl_name}-%{version}/{CREDITS,README,LICENSE} %doc %{pecl_name}-%{version}/example.php %{pecl_name}-%{version}/memcache.php %config(noreplace) %{php_inidir}/%{pecl_name}.ini %config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini @@ -197,6 +218,9 @@ fi %changelog +* Mon Apr 08 2013 Remi Collet - 3.0.8-1 +- Update to 3.0.8 + * Fri Dec 29 2012 Remi Collet - 3.0.7-5 - add patch for https://bugs.php.net/59602 segfault in getExtendedStats -- cgit