[prev in list] [next in list] [prev in thread] [next in thread]
List: pecl-cvs
Subject: [PECL-CVS] cvs: pecl /memcache memcache.c package.xml php_memcache.h /memcache/tests 029.phpt 030.p
From: "Mikael Johansson" <mikl () php ! net>
Date: 2006-04-28 9:55:48
Message-ID: cvsmikl1146218148 () cvsserver
[Download RAW message or body]
mikl Fri Apr 28 09:55:48 2006 UTC
Added files:
/pecl/memcache/tests 030.phpt
Modified files:
/pecl/memcache memcache.c package.xml php_memcache.h
/pecl/memcache/tests 029.phpt
Log:
Moved "memcache.allow_failover" and "memcache.chunk_size" ini directives into \
MODULE_GLOBALS Changed ini directives to STD_PHP_INI_ENTRY and added input \
validation
http://cvs.php.net/viewcvs.cgi/pecl/memcache/memcache.c?r1=1.44&r2=1.45&diff_format=u
Index: pecl/memcache/memcache.c
diff -u pecl/memcache/memcache.c:1.44 pecl/memcache/memcache.c:1.45
--- pecl/memcache/memcache.c:1.44 Sun Apr 23 19:35:26 2006
+++ pecl/memcache/memcache.c Fri Apr 28 09:55:48 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: memcache.c,v 1.44 2006/04/23 19:35:26 mikl Exp $ */
+/* $Id: memcache.c,v 1.45 2006/04/28 09:55:48 mikl Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -118,11 +118,26 @@
ZEND_GET_MODULE(memcache)
#endif
+static PHP_INI_MH(OnUpdateChunkSize) /* {{{ */
+{
+ char *endptr = NULL;
+ long int lval;
+
+ lval = strtol(new_value, &endptr, 10);
+ if (NULL != endptr && new_value + new_value_length != endptr || lval <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "memcache.chunk_size must be a \
positive integer ('%s' given)", new_value); + return FAILURE;
+ }
+
+ return OnUpdateInt(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, \
stage TSRMLS_CC); +}
+/* }}} */
+
/* {{{ PHP_INI */
PHP_INI_BEGIN()
- PHP_INI_ENTRY("memcache.allow_failover", "1", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("memcache.default_port", "11211", PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("memcache.chunk_size", "8192", PHP_INI_ALL, NULL)
+ STD_PHP_INI_ENTRY("memcache.allow_failover", "1", PHP_INI_ALL, OnUpdateInt, \
allow_failover, zend_memcache_globals, memcache_globals) + \
STD_PHP_INI_ENTRY("memcache.default_port", "11211", PHP_INI_ALL, OnUpdateInt, \
default_port, zend_memcache_globals, memcache_globals) + \
STD_PHP_INI_ENTRY("memcache.chunk_size", "8192", PHP_INI_ALL, OnUpdateChunkSize, \
chunk_size, zend_memcache_globals, memcache_globals) PHP_INI_END()
/* }}} */
@@ -255,7 +270,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "memcache support", "enabled");
php_info_print_table_row(2, "Active persistent connections", buf);
- php_info_print_table_row(2, "Revision", "$Revision: 1.44 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.45 $");
php_info_print_table_end();
}
/* }}} */
@@ -567,7 +582,7 @@
php_stream_auto_cleanup(mmc->stream);
php_stream_set_option(mmc->stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
php_stream_set_option(mmc->stream, PHP_STREAM_OPTION_WRITE_BUFFER, \
PHP_STREAM_BUFFER_NONE, NULL);
- php_stream_set_chunk_size(mmc->stream, INI_INT("memcache.chunk_size"));
+ php_stream_set_chunk_size(mmc->stream, MEMCACHE_G(chunk_size));
mmc->status = MMC_STATUS_CONNECTED;
return 1;
@@ -665,7 +680,7 @@
mmc = pool->buckets[hash % pool->num_buckets];
/* perform failover if needed */
- for (i=0; !mmc_open(mmc, 0, NULL, NULL TSRMLS_CC) && (i<20 || i<pool->num_buckets) \
&& INI_BOOL("memcache.allow_failover"); i++) { + for (i=0; !mmc_open(mmc, 0, NULL, \
NULL TSRMLS_CC) && (i<20 || i<pool->num_buckets) && MEMCACHE_G(allow_failover); i++) \
{ char *next_key = emalloc(key_len + MAX_LENGTH_OF_LONG + 1);
int next_len = sprintf(next_key, "%d%s", i+1, key);
MMC_DEBUG(("mmc_server_find: failed to connect to server '%s:%d' status %d, \
trying next", mmc->host, mmc->port, mmc->status)); @@ -1465,7 +1480,7 @@
mmc_pool_t *pool;
int errnum = 0, host_len;
char *host, *error_string = NULL;
- long port = INI_INT("memcache.default_port"), timeout = MMC_DEFAULT_TIMEOUT;
+ long port = MEMCACHE_G(default_port), timeout = MMC_DEFAULT_TIMEOUT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, \
&port, &timeout) == FAILURE) { return;
@@ -1532,7 +1547,7 @@
zval **connection, *mmc_object = getThis();
mmc_pool_t *pool;
mmc_t *mmc;
- long port = INI_INT("memcache.default_port"), weight = 1, timeout = \
MMC_DEFAULT_TIMEOUT, retry_interval = MMC_DEFAULT_RETRY; + long port = \
MEMCACHE_G(default_port), weight = 1, timeout = MMC_DEFAULT_TIMEOUT, retry_interval = \
MMC_DEFAULT_RETRY; zend_bool persistent = 1;
int resource_type, host_len;
char *host;
http://cvs.php.net/viewcvs.cgi/pecl/memcache/package.xml?r1=1.16&r2=1.17&diff_format=u
Index: pecl/memcache/package.xml
diff -u pecl/memcache/package.xml:1.16 pecl/memcache/package.xml:1.17
--- pecl/memcache/package.xml:1.16 Wed Apr 12 21:17:16 2006
+++ pecl/memcache/package.xml Fri Apr 28 09:55:48 2006
@@ -29,6 +29,7 @@
<notes>
- Added "memcache.default_port" ini directive (default 11211)
- Added "memcache.allow_failover" ini directive (default On)
+ - Added "memcache.chunk_size" ini directive (default 8192 bytes)
- Fixed PECL bug #7331 (NULL pointer freeing causes memcache to segfault)
</notes>
</release>
http://cvs.php.net/viewcvs.cgi/pecl/memcache/php_memcache.h?r1=1.13&r2=1.14&diff_format=u
Index: pecl/memcache/php_memcache.h
diff -u pecl/memcache/php_memcache.h:1.13 pecl/memcache/php_memcache.h:1.14
--- pecl/memcache/php_memcache.h:1.13 Mon Feb 6 19:48:20 2006
+++ pecl/memcache/php_memcache.h Fri Apr 28 09:55:48 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_memcache.h,v 1.13 2006/02/06 19:48:20 mikl Exp $ */
+/* $Id: php_memcache.h,v 1.14 2006/04/28 09:55:48 mikl Exp $ */
#ifndef PHP_MEMCACHE_H
#define PHP_MEMCACHE_H
@@ -104,6 +104,8 @@
long default_port;
long num_persistent;
long compression_level;
+ long allow_failover;
+ long chunk_size;
ZEND_END_MODULE_GLOBALS(memcache)
#ifdef ZTS
http://cvs.php.net/viewcvs.cgi/pecl/memcache/tests/029.phpt?r1=1.3&r2=1.4&diff_format=u
Index: pecl/memcache/tests/029.phpt
diff -u pecl/memcache/tests/029.phpt:1.3 pecl/memcache/tests/029.phpt:1.4
--- pecl/memcache/tests/029.phpt:1.3 Sun Feb 5 13:04:40 2006
+++ pecl/memcache/tests/029.phpt Fri Apr 28 09:55:48 2006
@@ -1,5 +1,5 @@
--TEST--
-INI_BOOL("memcache.allow_failover")
+ini_set("memcache.allow_failover")
--SKIPIF--
<?php if(!extension_loaded("memcache")) print "skip"; ?>
--FILE--
@@ -34,6 +34,10 @@
var_dump($result5);
var_dump($result6);
+$result7 = ini_set('memcache.allow_failover', "abc");
+
+var_dump($result7);
+
?>
--EXPECTF--
bool(true)
@@ -42,3 +46,4 @@
string(5) "test2"
bool(false)
string(5) "test2"
+string(1) "0"
http://cvs.php.net/viewcvs.cgi/pecl/memcache/tests/030.phpt?view=markup&rev=1.1
Index: pecl/memcache/tests/030.phpt
+++ pecl/memcache/tests/030.phpt
--TEST--
ini_set("memcache.chunk_size")
--SKIPIF--
<?php if(!extension_loaded("memcache")) print "skip"; ?>
--FILE--
<?php
include 'connect.inc';
$result1 = ini_set("memcache.chunk_size", 16384);
var_dump($result1);
$result2 = ini_set("memcache.chunk_size", 32768);
var_dump($result2);
$result3 = ini_get("memcache.chunk_size");
var_dump($result3);
$result4 = @ini_set("memcache.chunk_size", 0);
var_dump($result4);
$result5 = @ini_set("memcache.chunk_size", -1);
var_dump($result5);
?>
--EXPECTF--
string(%d) "%d"
string(5) "16384"
string(5) "32768"
string(5) "32768"
string(5) "32768"
--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic