mirror of
https://github.com/phpredis/phpredis.git
synced 2026-06-19 07:35:31 +00:00
Issue #1048
Add --with-liblzf configure option to use system liblzf. Use exponentially growing buffer for lzf_decompress. Move liblzf files to separeted dir in package.xml.
This commit is contained in:
@@ -14,6 +14,9 @@ PHP_ARG_ENABLE(redis-igbinary, whether to enable igbinary serializer support,
|
||||
PHP_ARG_ENABLE(redis-lzf, whether to enable lzf compression,
|
||||
[ --enable-redis-lzf Enable lzf compression support], no, no)
|
||||
|
||||
PHP_ARG_WITH(liblzf, use system liblzf,
|
||||
[ --with-liblzf[=DIR] Use system liblzf], no, no)
|
||||
|
||||
if test "$PHP_REDIS" != "no"; then
|
||||
|
||||
if test "$PHP_REDIS_SESSION" != "no"; then
|
||||
@@ -63,10 +66,35 @@ dnl Check for igbinary
|
||||
fi
|
||||
|
||||
if test "$PHP_REDIS_LZF" != "no"; then
|
||||
PHP_ADD_INCLUDE(liblzf)
|
||||
PHP_ADD_BUILD_DIR(liblzf)
|
||||
lzf_sources="liblzf/lzf_c.c liblzf/lzf_d.c"
|
||||
AC_DEFINE(HAVE_REDIS_LZF, 1, [ ])
|
||||
if test "$PHP_LIBLZF" != "no"; then
|
||||
AC_MSG_CHECKING(for liblzf files in default path)
|
||||
for i in $PHP_LIBLZF /usr/local /usr; do
|
||||
if test -r $i/include/lzf.h; then
|
||||
AC_MSG_RESULT(found in $i)
|
||||
LIBLZF_DIR=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$LIBLZF_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the liblzf distribution])
|
||||
fi
|
||||
PHP_CHECK_LIBRARY(lzf, lzf_compress,
|
||||
[
|
||||
PHP_ADD_LIBRARY_WITH_PATH(lzf, $LIBLZF_DIR/lib, LZF_SHARED_LIBADD)
|
||||
], [
|
||||
AC_MSG_ERROR([could not find usable liblzf])
|
||||
], [
|
||||
-L$LIBLZF_DIR/lib
|
||||
])
|
||||
PHP_SUBST(LZF_SHARED_LIBADD)
|
||||
else
|
||||
PHP_ADD_INCLUDE(liblzf)
|
||||
PHP_ADD_INCLUDE($ext_srcdir/liblzf)
|
||||
PHP_ADD_BUILD_DIR(liblzf)
|
||||
lzf_sources="liblzf/lzf_c.c liblzf/lzf_d.c"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl # --with-redis -> check with-path
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "igbinary/igbinary.h"
|
||||
#endif
|
||||
#ifdef HAVE_REDIS_LZF
|
||||
#include "lzf.h"
|
||||
#include <lzf.h>
|
||||
#endif
|
||||
#include <zend_exceptions.h>
|
||||
#include "php_redis.h"
|
||||
@@ -1822,9 +1822,12 @@ redis_unpack(RedisSock *redis_sock, const char *val, int val_len, zval *z_ret TS
|
||||
case REDIS_COMPRESSION_LZF:
|
||||
#ifdef HAVE_REDIS_LZF
|
||||
errno = E2BIG;
|
||||
for (i = 1; errno == E2BIG; ++i) {
|
||||
/* start from two-times bigger buffer and
|
||||
* increase it exponentially if needed */
|
||||
for (i = 2; errno == E2BIG; i *= 2) {
|
||||
data = emalloc(i * val_len);
|
||||
if ((res = lzf_decompress(val, val_len, data, i * val_len)) == 0) {
|
||||
/* errno != E2BIG will brake for loop */
|
||||
efree(data);
|
||||
continue;
|
||||
} else if (redis_unserialize(redis_sock, data, res, z_ret TSRMLS_CC) == 0) {
|
||||
|
||||
+14
-10
@@ -67,34 +67,38 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<file role='doc' name='COPYING'/>
|
||||
<file role='doc' name='CREDITS'/>
|
||||
<file role='doc' name='README.markdown'/>
|
||||
<file role='doc' name='arrays.markdown'/>
|
||||
<file role='doc' name='cluster.markdown'/>
|
||||
<file role='doc' name='CREDITS'/>
|
||||
<file role='doc' name='COPYING'/>
|
||||
<file role='src' name='cluster_library.c'/>
|
||||
<file role='src' name='cluster_library.h'/>
|
||||
<file role='src' name='common.h'/>
|
||||
<file role='src' name='config.m4'/>
|
||||
<file role='src' name='config.w32'/>
|
||||
<file role='src' name='common.h'/>
|
||||
<file role='src' name='crc16.h'/>
|
||||
<file role='src' name='library.c'/>
|
||||
<file role='src' name='library.h'/>
|
||||
<file role='src' name='php_redis.h'/>
|
||||
<file role='src' name='redis.c'/>
|
||||
<file role='src' name='redis_array.c'/>
|
||||
<file role='src' name='redis_array.h'/>
|
||||
<file role='src' name='redis_array_impl.c'/>
|
||||
<file role='src' name='redis_array_impl.h'/>
|
||||
<file role='src' name='redis_cluster.c'/>
|
||||
<file role='src' name='redis_cluster.h'/>
|
||||
<file role='src' name='cluster_library.c'/>
|
||||
<file role='src' name='cluster_library.h'/>
|
||||
<file role='src' name='redis_commands.c'/>
|
||||
<file role='src' name='redis_commands.h'/>
|
||||
<file role='src' name='redis.c'/>
|
||||
<file role='src' name='crc16.h'/>
|
||||
<file role='src' name='redis_session.c'/>
|
||||
<file role='src' name='redis_session.h'/>
|
||||
<file role='src' name='liblzf/lzf.h'/>
|
||||
<file role='src' name='liblzf/lzf_c.c'/>
|
||||
<file role='src' name='liblzf/lzf_d.c'/>
|
||||
<dir name='liblzf'>
|
||||
<file role='doc' name='LICENSE'/>
|
||||
<file role='doc' name='README'/>
|
||||
<file role='src' name='lzf.h'/>
|
||||
<file role='src' name='lzf_c.c'/>
|
||||
<file role='src' name='lzf_d.c'/>
|
||||
</dir> <!-- liblzf -->
|
||||
<dir name='tests'>
|
||||
<file role='test' name='RedisArrayTest.php'/>
|
||||
<file role='test' name='RedisClusterTest.php'/>
|
||||
|
||||
Reference in New Issue
Block a user