Browse code

pecl-apc fix warnings

Hanno Böck authored on 09/01/2013 12:56:43
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+AUX APC-3.1.13-fix-warnings.diff 4443 SHA256 9011a75d6a6da5e2fdec02d7daa08c68f223aea9728545c93dff7ceab235cca8 SHA512 a34e4df617ecb75fcc3d2594c217b2291897444bc6a65a1aeeaad20ce7434505b93b52e0ef902cb00da11ff79391287e998f6494eb34cdc91bcfdcc797aa989e WHIRLPOOL 3193d1af3bae3ff43819c70cfb18be956621ec2e6a0cb2ea729d6bd477de173b8e7b990cbce78a3ffc4c46b0057968ed1c9bb33f648ddf0195688532c6978be6
2
+AUX pecl-apc.ini 233 SHA256 1529ee803ce25a13bd303c9b40a32b238daf21aa0a993d8e66ae90dc1042d080 SHA512 ec206fd3fc6ebda209e2ff19db7910c7deeced53e8041b9ba5283684cde84144c99ea7521b9291b6b62c6cbc8fdd219bb9141fa11df75b76688d9e706b59c985 WHIRLPOOL 6ee07613551c3032a39296f516caff0b4f25e2cd0e2431af56b945986000146cdc6f585f607041258aecef9351c6852885082ccd6e3fca3c6c0e32db593d3c21
3
+DIST APC-3.1.13.tgz 171591 SHA256 5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd SHA512 4ccfa12a61a9276be207c9b70b108b725cf2faa3ed805bab8c9a39b04039fd16a8da6919ab7d5a84592f7b4a7827dcd9adeb154c6a04d208e7071be22268b332 WHIRLPOOL 335020f6ec44ec188b9544fb4132d2c1c62c4d342c3e07f3bfb0266c3827c311316c95ec08517946481724350314a06e7f3b49b13c0cedf2a2dcd1ca5d38149e
4
+EBUILD pecl-apc-3.1.13.ebuild 1703 SHA256 0137e5ac0ac8fe866b8ea8aa567a57ecf005629bda61ebbce3cd5c2256dda995 SHA512 1b09f8b1a2719ab6d79ec4d01322d39ae9f850c779b11e59202a91d216248c365fc98778b62f2310c54a1039182c3f225f9d2ef741e40241affda8a4e4a30d18 WHIRLPOOL 6f4c6cefce1ff34beeca906cf2e78d945875c8f0f48cd1c3cfd843e2e4c55ff64232a845f75e52b1d4b8e2c44baa2c1bf8acfb12b79c5980616c46a1a0b2485f
0 5
new file mode 100644
... ...
@@ -0,0 +1,86 @@
1
+diff -Naur APC-3.1.13/apc_bin.c APC-3.1.13-fix-warnings/apc_bin.c
2
+--- APC-3.1.13/apc_bin.c	2012-09-03 18:52:51.000000000 +0200
3
+@@ -719,7 +719,7 @@
4
+     apc_bd_alloc_ex(pool_ptr, sizeof(apc_pool) TSRMLS_CC);
5
+     ctxt.pool = apc_pool_create(APC_UNPOOL, apc_bd_alloc, apc_bd_free, NULL, NULL TSRMLS_CC);  /* ideally the pool wouldn't be alloc'd as part of this */
6
+     if (!ctxt.pool) { /* TODO need to cleanup */
7
+-        apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
8
++        php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
9
+         return NULL;
10
+     }
11
+     ctxt.copy = APC_COPY_IN_OPCODE; /* avoid stupid ALLOC_ZVAL calls here, hack */
12
+@@ -894,7 +894,7 @@
13
+     for(i = 0; i < bd->num_entries; i++) {
14
+         ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
15
+         if (!ctxt.pool) { /* TODO need to cleanup previous pools */
16
+-            apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
17
++            php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
18
+             goto failure;
19
+         }
20
+         ep = &bd->entries[i];
21
+diff -Naur APC-3.1.13/apc_cache.c APC-3.1.13-fix-warnings/apc_cache.c
22
+--- APC-3.1.13/apc_cache.c	2012-09-03 18:52:51.000000000 +0200
23
+@@ -1334,6 +1334,7 @@
24
+ /* {{{ apc_cache_is_last_key */
25
+ zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t TSRMLS_DC)
26
+ {
27
++    char *log_message;
28
+     apc_keyid_t *lastkey = &cache->header->lastkey;
29
+     unsigned int keylen = key->data.user.identifier_len;
30
+ #ifdef ZTS
31
+@@ -1350,7 +1351,10 @@
32
+         if(lastkey->mtime == t && FROM_DIFFERENT_THREAD(lastkey)) {
33
+             /* potential cache slam */
34
+             if(APCG(slam_defense)) {
35
+-                apc_debug("Potential cache slam averted for key '%s'" TSRMLS_CC, key->data.user.identifier);
36
++                log_message = emalloc((key->data.user.identifier_len + 40) * sizeof(char));
37
++                sprintf(log_message, "Potential cache slam averted for key '%s'", key->data.user.identifier);
38
++                php_log_err(log_message TSRMLS_CC);
39
++                efree(log_message);
40
+                 return 1;
41
+             }
42
+         }
43
+diff -Naur APC-3.1.13/apc_main.c APC-3.1.13-fix-warnings/apc_main.c
44
+--- APC-3.1.13/apc_main.c	2012-09-03 18:52:51.000000000 +0200
45
+@@ -403,7 +403,7 @@
46
+     ctxt.pool = apc_pool_create(APC_MEDIUM_POOL, apc_sma_malloc, apc_sma_free, 
47
+                                                  apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
48
+     if (!ctxt.pool) {
49
+-        apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
50
++        php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
51
+         return FAILURE;
52
+     }
53
+     ctxt.copy = APC_COPY_IN_OPCODE;
54
+@@ -528,7 +528,7 @@
55
+         ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free,
56
+                                                 apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
57
+         if (!ctxt.pool) {
58
+-            apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
59
++            php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
60
+             return old_compile_file(h, type TSRMLS_CC);
61
+         }
62
+         ctxt.copy = APC_COPY_OUT_OPCODE;
63
+diff -Naur APC-3.1.13/php_apc.c APC-3.1.13-fix-warnings/php_apc.c
64
+--- APC-3.1.13/php_apc.c	2012-09-03 18:52:51.000000000 +0200
65
+@@ -589,7 +589,7 @@
66
+     ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
67
+     if (!ctxt.pool) {
68
+         HANDLE_UNBLOCK_INTERRUPTIONS();
69
+-        apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
70
++        php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
71
+         return 0;
72
+     }
73
+     ctxt.copy = APC_COPY_IN_USER;
74
+@@ -838,7 +838,7 @@
75
+ 
76
+     ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL TSRMLS_CC);
77
+     if (!ctxt.pool) {
78
+-        apc_warning("Unable to allocate memory for pool." TSRMLS_CC);
79
++        php_log_err("Unable to allocate memory for pool." TSRMLS_CC);
80
+         RETURN_FALSE;
81
+     }
82
+     ctxt.copy = APC_COPY_OUT_USER;
0 83
new file mode 100644
... ...
@@ -0,0 +1,11 @@
1
+apc.enabled="1"
2
+apc.shm_segments="1"
3
+apc.shm_size="30M"
4
+apc.mmap_file_mask="/tmp/apcphp5.XXXXXX"
5
+apc.file_update_protection="2"
6
+apc.enable_cli="0"
7
+apc.max_file_size="1M"
8
+apc.stat="1"
9
+apc.write_lock="1"
10
+apc.include_once_override="0"
11
+
0 12
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+# Copyright 1999-2012 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/dev-php/pecl-apc/pecl-apc-3.1.13.ebuild,v 1.1 2012/09/04 12:29:31 olemarkus Exp $
4
+
5
+EAPI=4
6
+
7
+PHP_EXT_NAME="apc"
8
+PHP_EXT_PECL_PKG="APC"
9
+PHP_EXT_INI="yes"
10
+PHP_EXT_ZENDEXT="no"
11
+DOCS="CHANGELOG INSTALL NOTICE TECHNOTES.txt TODO"
12
+
13
+PHP_EXT_INIFILE="${PN}.ini"
14
+
15
+USE_PHP="php5-3 php5-4"
16
+
17
+inherit php-ext-pecl-r2 confutils eutils
18
+
19
+KEYWORDS="~amd64 ~mips ~ppc ~ppc64 ~x86"
20
+
21
+DESCRIPTION="A free, open, and robust framework for caching and optimizing PHP code."
22
+LICENSE="PHP-3.01"
23
+SLOT="0"
24
+IUSE="mmap"
25
+
26
+DEPEND="!dev-php/eaccelerator !dev-php/xcache"
27
+RDEPEND="${DEPEND}"
28
+
29
+LOCKS="pthreadmutex pthreadrw spinlock semaphore"
30
+
31
+LUSE=""
32
+for l in ${LOCKS}; do
33
+	LUSE+="lock_${l} "
34
+done
35
+
36
+IUSE+=" ${LUSE/lock_pthreadmutex/+lock_pthreadmutex}"
37
+
38
+REQUIRED_USE="^^ ( $LUSE )"
39
+
40
+src_prepare() {
41
+	local slot
42
+	for slot in $(php_get_slots); do
43
+		php_init_slot_env ${slot}
44
+		epatch "${FILESDIR}"/APC-3.1.13-fix-warnings.diff
45
+	done
46
+	php-ext-source-r2_src_prepare
47
+}
48
+
49
+
50
+src_configure() {
51
+	my_conf="--enable-apc"
52
+	enable_extension_enable "apc-mmap" "mmap" 0
53
+
54
+	enable_extension_enable "apc-pthreadmutex" "lock_pthreadmutex" 0
55
+	enable_extension_enable "apc-pthreadrwlocks" "lock_pthreadrw" 0
56
+	enable_extension_enable "apc-spinlocks" "lock_spinlock" 0
57
+	enable_extension_enable "apc-sem" "lock_semaphore" 0
58
+
59
+	php-ext-source-r2_src_configure
60
+}
61
+
62
+src_install() {
63
+	php-ext-pecl-r2_src_install
64
+
65
+	dodir "${PHP_EXT_SHARED_DIR}"
66
+	insinto "${PHP_EXT_SHARED_DIR}"
67
+	doins apc.php
68
+}
69
+
70
+pkg_postinst() {
71
+	elog "The apc.php file shipped with this release of PECL-APC was"
72
+	elog "installed into ${PHP_EXT_SHARED_DIR}/."
73
+}