From 42bb333a550d9bda2492d0cf7ed66bcdc35e569d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 27 Jul 2013 14:02:05 +0200 Subject: php-pecl-apcu: restore APC serializers ABI --- apcu-git.patch | 301 ++++++++++++++++++++++++++++++++++++++++++++++++----- php-pecl-apcu.spec | 12 ++- 2 files changed, 285 insertions(+), 28 deletions(-) diff --git a/apcu-git.patch b/apcu-git.patch index 9f6e922..b595a48 100644 --- a/apcu-git.patch +++ b/apcu-git.patch @@ -1,38 +1,289 @@ -From d192f6081164ba5ec5b05dce8e5c0b50b5d7b35d Mon Sep 17 00:00:00 2001 -From: krakjoe -Date: Thu, 28 Mar 2013 20:27:16 +0000 -Subject: [PATCH] forcefully align frequent structs (gcc >= 3.1), in testing - (windows anyone?) stop crash in cli when cache is disabled by configuration - and some userland functions are executed +From 286f70d4a921c0cd21f59f8db8efd2fa45e8d559 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 8 Jul 2013 14:23:05 +0200 +Subject: [PATCH 1/4] restore APC hook for register serializer, fix #24 --- - apc.h | 5 ++++- - apc_cache.c | 4 ++-- - apc_cache_api.h | 12 +++++++----- - php_apc.c | 3 +-- - 4 files changed, 14 insertions(+), 10 deletions(-) + apc.c | 4 +-- + apc.h | 19 +++---------- + apc_serializer.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + config.m4 | 2 +- + config.w32 | 2 +- + php_apc.c | 7 ++++- + 6 files changed, 98 insertions(+), 20 deletions(-) + create mode 100644 apc_serializer.h +diff --git a/apc.c b/apc.c +index 86ed21f..7457b53 100644 +--- a/apc.c ++++ b/apc.c +@@ -370,8 +370,8 @@ HashTable* apc_flip_hash(HashTable *hash) { + /* }}} */ + + /* {{{ apc_register_serializer */ +-PHP_APCU_API zend_bool apc_register_serializer(const char* name, +- apc_serialize_t serialize, ++PHP_APCU_API int _apc_register_serializer(const char* name, ++ apc_serialize_t serialize, + apc_unserialize_t unserialize, + void *config TSRMLS_DC) { + int i; +diff --git a/apc.h b/apc.h +index cd1cb59..256ab01 100644 +--- a/apc.h ++++ b/apc.h +@@ -127,19 +127,8 @@ + + /* + * Serializer API +-* Note: This used to live in apc_serializer.h + */ +-#define APC_SERIALIZER_NAME(module) module##_apc_serializer +-#define APC_SERIALIZER_EXTERN(module) extern apc_serialize_t module##_apc_serializer +-#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer +-#define APC_UNSERIALIZER_EXTERN(module) extern apc_unserialize_t module##_apc_unserializer +- +-#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC +-#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC +- +-/* {{{ */ +-typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS); +-typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS); /* }}} */ ++#include "apc_serializer.h" + + /* {{{ struct definition: apc_serializer_t */ + typedef struct apc_serializer_t { +@@ -150,10 +139,10 @@ + } apc_serializer_t; + /* }}} */ + +-/* {{{ apc_register_serializer ++/* {{{ _apc_register_serializer + registers the serializer using the given name and paramters */ +-PHP_APCU_API zend_bool apc_register_serializer(const char* name, +- apc_serialize_t serialize, ++PHP_APCU_API int _apc_register_serializer(const char* name, ++ apc_serialize_t serialize, + apc_unserialize_t unserialize, + void *config TSRMLS_DC); /* }}} */ + +diff --git a/apc_serializer.h b/apc_serializer.h +new file mode 100644 +index 0000000..0bdaa08 +--- /dev/null ++++ b/apc_serializer.h +@@ -0,0 +1,84 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.txt. | ++ | If you did not receive a copy of the PHP license and are unable to | ++ | obtain it through the world-wide-web, please send a note to | ++ | license@php.net so we can mail you a copy immediately. | ++ +----------------------------------------------------------------------+ ++ | Authors: Gopal Vijayaraghavan | ++ +----------------------------------------------------------------------+ ++ ++ */ ++ ++/* $Id: $ */ ++ ++#ifndef APC_SERIALIZER_H ++#define APC_SERIALIZER_H ++ ++/* this is a shipped .h file, do not include any other header in this file */ ++#define APC_SERIALIZER_NAME(module) module##_apc_serializer ++#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer ++ ++#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC ++#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC ++ ++typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS); ++typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS); ++ ++typedef int (*apc_register_serializer_t)(const char* name, ++ apc_serialize_t serialize, ++ apc_unserialize_t unserialize, ++ void *config TSRMLS_DC); ++ ++/* ++ * ABI version for constant hooks. Increment this any time you make any changes ++ * to any function in this file. ++ */ ++#define APC_SERIALIZER_ABI "0" ++#define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI ++ ++#if !defined(APC_UNUSED) ++# if defined(__GNUC__) ++# define APC_UNUSED __attribute__((unused)) ++# else ++# define APC_UNUSED ++# endif ++#endif ++ ++static APC_UNUSED int apc_register_serializer(const char* name, ++ apc_serialize_t serialize, ++ apc_unserialize_t unserialize, ++ void *config TSRMLS_DC) ++{ ++ zval apc_magic_constant; ++ int retval = 0; ++ ++ /* zend_get_constant will return 1 on success, otherwise apc_magic_constant wouldn't be touched at all */ ++ if (zend_get_constant(APC_SERIALIZER_CONSTANT, sizeof(APC_SERIALIZER_CONSTANT)-1, &apc_magic_constant TSRMLS_CC)) { ++ apc_register_serializer_t register_func = (apc_register_serializer_t)(Z_LVAL(apc_magic_constant)); ++ if(register_func) { ++ retval = register_func(name, serialize, unserialize, NULL TSRMLS_CC); ++ } ++ zval_dtor(&apc_magic_constant); ++ } ++ ++ return retval; ++} ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff --git a/config.m4 b/config.m4 +index 8b73ba3..d4fb2fd 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -129,7 +129,7 @@ if test "$PHP_APCU" != "no"; then + PHP_NEW_EXTENSION(apcu, $apc_sources, $ext_shared,, \\$(APCU_CFLAGS)) + PHP_SUBST(APCU_SHARED_LIBADD) + PHP_SUBST(APCU_CFLAGS) +- PHP_INSTALL_HEADERS(ext/apcu, [apc.h apc_api.h apc_cache_api.h apc_lock_api.h apc_pool_api.h apc_sma_api.h apc_bin_api.h]) ++ PHP_INSTALL_HEADERS(ext/apcu, [apc.h apc_api.h apc_cache_api.h apc_lock_api.h apc_pool_api.h apc_sma_api.h apc_bin_api.h apc_serializer.h]) + AC_DEFINE(HAVE_APCU, 1, [ ]) + fi + diff --git a/php_apc.c b/php_apc.c -index 9849580..6dc0184 100644 +index afa69cd..ec1b57b 100644 --- a/php_apc.c +++ b/php_apc.c -@@ -499,7 +499,7 @@ static void apc_store_helper(INTERNAL_FUNCTION_PARAMETERS, const zend_bool exclu - return; - } +@@ -281,6 +281,8 @@ static PHP_MINIT_FUNCTION(apcu) + apc_sma.init(APCG(shm_segments), APCG(shm_size), NULL TSRMLS_CC); + #endif -- if (!key) { -+ if (!key || !APCG(enabled)) { - /* cannot work without key */ ++ REGISTER_LONG_CONSTANT(APC_SERIALIZER_CONSTANT, (long)&_apc_register_serializer, CONST_PERSISTENT | CONST_CS); ++ + /* register default serializer */ + apc_register_serializer( + "php", APC_SERIALIZER_NAME(php), APC_UNSERIALIZER_NAME(php), NULL TSRMLS_CC); +@@ -288,7 +290,10 @@ static PHP_MINIT_FUNCTION(apcu) + /* register eval serializer */ + apc_register_serializer( + "eval", APC_SERIALIZER_NAME(eval), APC_UNSERIALIZER_NAME(eval), NULL TSRMLS_CC); +- ++ ++ /* test out the constant function pointer */ ++ assert(apc_serializers[0].name != NULL); ++ + /* create user cache */ + apc_user_cache = apc_cache_create( + &apc_sma, +-- +1.8.1.6 + + +From 07afc5b8cf67c71903f71f1dd6c768112e5798eb Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 8 Jul 2013 14:25:48 +0200 +Subject: [PATCH 2/4] php_apc.c:1124:16: warning: variable 'h_files' set but + not used [-Wunused-but-set-variable] + +--- + php_apc.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/php_apc.c b/php_apc.c +index ec1b57b..10a5df3 100644 +--- a/php_apc.c ++++ b/php_apc.c +@@ -1121,7 +1121,7 @@ void *apc_erealloc_wrapper(void *ptr, size_t size) { + PHP_FUNCTION(apc_bin_dumpfile) { + + zval *z_files = NULL, *z_user_vars = NULL; +- HashTable *h_files, *h_user_vars; ++ HashTable *h_user_vars; + char *filename = NULL; + int filename_len; + long flags=0; +@@ -1146,7 +1146,6 @@ void *apc_erealloc_wrapper(void *ptr, size_t size) { RETURN_FALSE; } -@@ -941,7 +941,6 @@ void *apc_erealloc_wrapper(void *ptr, size_t size) { - HashTable *h_vars; - apc_bd_t *bd; -- - if (!APCG(enabled)) { - apc_warning("APC is not enabled, apc_bin_dump not available." TSRMLS_CC); - RETURN_FALSE; +- h_files = z_files ? Z_ARRVAL_P(z_files) : NULL; + h_user_vars = z_user_vars ? Z_ARRVAL_P(z_user_vars) : NULL; + bd = apc_bin_dump(apc_user_cache, h_user_vars TSRMLS_CC); + if(!bd) { +-- +1.8.1.6 + + +From 0c1d7d3af957f4d06c1265bd1b2752007c56ef53 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 8 Jul 2013 14:29:43 +0200 +Subject: [PATCH 3/4] apc_cache.c:300:5: warning: pointer targets in passing + argument 1 of 'php_stream_open_for_zend_ex' differ in signedness + [-Wpointer-sign] + +--- + apc_cache.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/apc_cache.c b/apc_cache.c +index c7a1b7b..23c761b 100644 +--- a/apc_cache.c ++++ b/apc_cache.c +@@ -297,7 +297,7 @@ PHP_APCU_API int APC_UNSERIALIZER_NAME(eval) (APC_UNSERIALIZER_ARGS) + { + zend_file_handle zhandle; + +- if (php_stream_open_for_zend_ex(buf, &zhandle, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { ++ if (php_stream_open_for_zend_ex((const char *)buf, &zhandle, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) { + zend_op_array *op_array = zend_compile_file(&zhandle, ZEND_INCLUDE TSRMLS_CC); + zend_op_array *active_op_array = EG(active_op_array); + zval **return_value_ptr_ptr = EG(return_value_ptr_ptr); +-- +1.8.1.6 + + +From 38ef422d01422e7ce1059a60e87e5f10a6da7294 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Sat, 27 Jul 2013 08:10:26 +0200 +Subject: [PATCH 4/4] fix apc_serializers undefined + +--- + php_apc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/php_apc.c b/php_apc.c +index 10a5df3..dccdd37 100644 +--- a/php_apc.c ++++ b/php_apc.c +@@ -292,7 +292,7 @@ static PHP_MINIT_FUNCTION(apcu) + "eval", APC_SERIALIZER_NAME(eval), APC_UNSERIALIZER_NAME(eval), NULL TSRMLS_CC); + + /* test out the constant function pointer */ +- assert(apc_serializers[0].name != NULL); ++ assert(apc_get_serializers()->name != NULL); + + /* create user cache */ + apc_user_cache = apc_cache_create( -- 1.8.1.6 diff --git a/php-pecl-apcu.spec b/php-pecl-apcu.spec index d708cc8..0e192ce 100644 --- a/php-pecl-apcu.spec +++ b/php-pecl-apcu.spec @@ -19,6 +19,10 @@ Source1: %{pecl_name}.ini Source2: %{pecl_name}-panel.conf Source3: %{pecl_name}.conf.php +# Restore APC serializers ABI (merged upstream) +# https://github.com/krakjoe/apcu/pull/25 +Patch0: %{pecl_name}-git.patch + License: PHP Group: Development/Languages URL: http://pecl.php.net/package/APCu @@ -38,7 +42,7 @@ Provides: php-apcu%{?_isa} = %{version} Provides: php-pecl(apcu) = %{version} Provides: php-pecl(apcu)%{?_isa} = %{version} %if "%{php_version}" < "5.5" -Conflicts: php-pecl-apc +Conflicts: php-pecl-apc < 4 %else Obsoletes: php-pecl-apc < 4 %endif @@ -82,7 +86,7 @@ Group: Development/Libraries Requires: %{name}%{?_isa} = %{version}-%{release} Requires: php-devel%{?_isa} %if "%{php_version}" < "5.5" -Conflicts: php-pecl-apc-devel +Conflicts: php-pecl-apc-devel < 4 %else Obsoletes: php-pecl-apc-devel < 4 Provides: php-pecl-apc-devel = %{version}-%{release} @@ -102,7 +106,7 @@ BuildArch: noarch Requires: %{name} = %{version}-%{release} Requires: mod_php, httpd, php-gd %if "%{php_version}" < "5.5" -Conflicts: apc-panel +Conflicts: apc-panel < 4 %else Obsoletes: apc-panel < 4 Provides: apc-devel = %{version}-%{release} @@ -118,6 +122,7 @@ configuration, available on http://localhost/apcu-panel/ mv %{pecl_name}-%{version} NTS cd NTS +%patch0 -p1 -b .serializers # Sanity check, really often broken extver=$(sed -n '/#define PHP_APC_VERSION/{s/.* "//;s/".*$//;p}' php_apc.h) @@ -237,6 +242,7 @@ rm -rf %{buildroot} %changelog * Thu Jul 4 2013 Remi Collet - 4.0.1-2 - obsoletes APC with php 5.5 +- restore APC serializers ABI (patch merged upstream) * Tue Apr 30 2013 Remi Collet - 4.0.1-1 - Update to 4.0.1 -- cgit