120 Commits

Author SHA1 Message Date
michael-grunder
5ca626a365 More memory leak fixes 2016-02-14 15:18:17 -08:00
michael-grunder
ddb6edf9c8 Memory leak fixes 2016-02-13 17:03:20 -08:00
michael-grunder
7b36957682 Various memory related fixes for php7
The php7 api has substantial changes in the way one goes about
interacting with the zval type (php's internal structure for dealing
with dynamically typed variables).

Most notably, most everything is dereferenced by one pointer.  So,
where you once used zval** you typically use zval*, and where you
used zval* you now just use a zval struct on the stack.

In addition, the api changed in how you return a string.  Previously
you had the option of whether or not to "duplicate" the memory returned
(or in other words, pass ownership of the pointer to PHP or not).

Because phpredis sometimes buffers commands to the server (say in the
case of a pipeline, or a MULTI/EXEC) transaction, we had several stack
violations and/or memory corruption which resulted from keeping track
of the address of a stack allocated structure, which was accessed at
a later date (sometimes causing segmentation faults, bus errors, etc).

Also, there were a few places where this pattern was being used:

zval **ptr = emalloc(sizeof(zval*) * count);
/* stuff */
ZVAL_STRING(ptr[0], "hello world");

Given that ZVAL_STRING() thinks it's writing to an allocated structure
it would cause various random issues (because we were blowing through
the data segment and writing into the code section).

This commit (so far) fixes all of the segmentation faults and memory
errors but there are still leaks (specifically in RedisArray) that need
to be solved.

Addresses #727
2016-01-25 12:55:41 -08:00
michael-grunder
64ba85e469 Attempted solution to #707 and cleaned up some memory leaks/invalid frees 2015-12-19 13:57:29 -08:00
michael-grunder
de368c6664 Fix segfault for php7 and RedisArray
Addresses #707
2015-12-18 13:39:07 -08:00
Jan-E
2ee2b2a273 Fix signed/unsigned mismatch 2015-09-09 02:40:38 +00:00
Jan-E
4d66e3d4c0 Fix incompatible types 2015-09-09 02:40:38 +00:00
Sean DuBois
9cb9d075de Fix compile errors in redis_session.c 2015-09-08 19:13:09 +00:00
Sean DuBois
cbdf65a765 Fixing test fails, no large changes mostly invalid frees and off-by-ones 2015-09-06 20:52:03 +00:00
Sean DuBois
f30b7fdb04 Use heap allocated zvals instead of dynamic arrays 2015-09-06 05:18:32 +00:00
Sean DuBois
c687a51322 * retab, some files had tabs instead of 4 spaces
* When converting zval from heap -> stack allocation some frees were left, causing invalid frees on stack values
* zend_parse* was use int instead of size_t when consuming strings, causing undefined behavior
2015-09-06 04:50:12 +00:00
Sean DuBois
9221ca465c Fix compile time errors for redis_array_impl.c 2015-09-03 23:09:23 +00:00
Sean DuBois
4e00df6618 Fix compile time errors for redis_array.c 2015-09-03 16:25:07 +00:00
michael-grunder
09f7a77294 Call zval destructor if we fall back to prevent leak 2015-01-29 15:31:15 -08:00
Michael Maclean
a308b81068 Replace calls to zend_hash_quick_find with NULL arguments 2015-01-28 16:03:05 +00:00
michael-grunder
da51f06bcd Merge branch 'int-ra-timeout' into develop 2014-10-22 13:52:52 -07:00
michael-grunder
c1f862c99d Remove debug line 2014-10-22 13:52:31 -07:00
michael-grunder
66cdeb6b59 Allow integer connect_timeout in RedisArray
Addresses #520
2014-10-20 12:20:57 -07:00
michael-grunder
0f1f5f444f Merge branch 'hotfix/win32-fixes' into develop
Conflicts:
	redis.c
2014-07-06 11:04:55 -07:00
Anatol Belski
cdd4557f01 fix unreferenced variable warnings 2014-07-01 16:59:41 +02:00
Anatol Belski
79efa8d791 fixes after the merge 2014-07-01 16:50:23 +02:00
Anatol Belski
4d2533706a Merge remote-tracking branch 'vostok4/master'
Conflicts:
	CREDITS
	README.markdown
	config.w32
	library.c
	library.h
	package.xml
	redis.c
	redis_array.c
	redis_array.h
	redis_array_impl.c
	redis_array_impl.h
	tests/TestRedis.php
2014-07-01 16:45:09 +02:00
Anatol Belski
6c377eee18 added redis array stuff to win part done some fixes to it 2014-07-01 12:19:01 +02:00
michael-grunder
52b3c95dab SAVE and BGSAVE are distrubte commands
SAVE and BGSAVE need to be passed through multihost_distribute

Refs #472
2014-05-15 12:11:16 -07:00
vostok4
566d673f83 Fix comments for C89 compatibility 2014-04-09 11:21:32 +02:00
vostok4
9c12c40a66 Merge nicolasff:b9a16b5ad5 in, fixing for Win32
Now we should be up to master with upstream for an easier merge.
2014-04-09 11:14:45 +02:00
michael-grunder
c81a95413d Merge branch 'hotfix/ra_autorehash' into develop
Conflicts:
	redis_array.c
2014-03-11 09:14:26 -07:00
michael-grunder
f72a3177a3 Fix autorehashing in RedisArray
This commit fixes auto rehashing in RedisArray as well as fixes
a couple of memory leaks found along the way

Addresses #442 and #294
2014-03-10 13:18:19 -07:00
Mike
6f5e47cec3 add support for 'connect_timeout' option for redis arrays
Conflicts:
	redis_array.c
	redis_array_impl.c
	redis_array_impl.h
2014-02-23 11:50:34 -08:00
michael-grunder
9eaf14756b Don't attempt MGET on nodes where no keys resolve
The MGET call in RedisArray was failing under circumstances where
none of the passed keys hashed into any given node in the ring.
What was happening is that RedisArray was passing through to the
phpredis MGET command an empty array, which was returning false.
This in turn caused RedisArray to abort the process and return
false as well.

This change updates RedisArray MGET such that if a given node
doesn't have any keys, we skip the call to it all together.

Addresses #435
Addresses #436
2014-02-21 06:12:32 -08:00
vostok4
978fbcf6fc Further fixes for building on VC9 Win32, C89 compliance
Include win32/php_stdint.h on Win32 (fixes compilation on VC9)
Change C++ comments to C89 style (to adhere to PHP project)
2013-10-18 14:37:06 +02:00
vostok4
b7e8b3b64e Fix compilation errors on Win32 with VC11
This brings the W32 compilation fixes done by @char101 up to date and
allows building of php_redis.dll with VC11 on Win32 (allows for a php5.5
version).
2013-10-10 13:07:01 +02:00
michael-grunder
7aae259ecb Fix argument order sent to ra_make_array 2013-08-11 11:50:38 -07:00
michael-grunder
f97c8433d5 Integrating mobli's lazy connect and retry interval 2013-08-11 11:31:23 -07:00
michael-grunder
8443769dc3 Merge remote-tracking branch 'mobli/develop' into feature/mobli_ra_changes
Conflicts:
	redis_array.c
	redis_array_impl.c
	redis_array_impl.h
2013-08-11 11:29:29 -07:00
michael-grunder
a80246122a Merge branch 'feature/ra_mset_intkeys' into develop 2013-08-11 09:13:04 -07:00
michael-grunder
dcbeae7599 Persistent connections with RedisArray
Re-integrating the now old ra-performance branch into a git-flow
branch.  I could have merged it but this was easier with so few
changes
2013-08-11 08:54:59 -07:00
michael-grunder
641841012f Make sure RedisArray::mget returns an array
Add a check in mget to make sure that the forwarded call is
returning with an array, and not NULL or something else.

Addresses issue #350
2013-08-06 14:17:54 -07:00
michael-grunder
98bc9ecbeb Formatting 2013-07-31 21:50:00 -07:00
michael-grunder
0ce690c8fe Allow for LONG and STRING keys in MGET and MSET. We can't allow
for other types, as phpredis proper takes a key->value array and
PHP doesn't support other array key types.

Addresses #360
2013-07-31 21:20:22 -07:00
Nicolas Favre-Felix
f9ef6efc7f Add FLUSHALL to RedisArray
GitHub issue #334
2013-05-02 19:59:27 +01:00
Nicolas Favre-Felix
5660e10c62 Add FLUSHDB to RedisArray
GitHub issue #334
2013-05-02 19:57:49 +01:00
michael-grunder
3e6d5b60d6 Cutting a release for 2.2.3. Added myself as a maintainer
in the header files
2013-04-28 11:09:58 -07:00
Emmanuel Merali
acd3245456 Added lazy_connect option to RedisArray
Added an option to let each RedisArray connection connect lazily to
their respective server. This is useful then working with a redis
cluster composed of many shards which are not necessarily in use all at
once.
2013-02-25 00:38:47 +02:00
Emmanuel Merali
6d3c9990a5 Merged changes from @mobli
New select DB command to RedisArray - Added retry delay on reconnect

Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
Also, fixed a compiler warning:
redis_array_impl.c:1115:15: warning: incompatible pointer types
assigning to 'zval **' (aka 'struct _zval_struct **') from 'zval
**(*)[2]' [-Wincompatible-pointer-types]

Conflicts:
	common.h
2013-02-22 09:35:22 -08:00
Emmanuel Merali
d4c7f64131 New select DB command to RedisArray - Added retry delay on reconnect
Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
Also, fixed a compiler warning:
redis_array_impl.c:1115:15: warning: incompatible pointer types
assigning to 'zval **' (aka 'struct _zval_struct **') from 'zval
**(*)[2]' [-Wincompatible-pointer-types]
2013-01-29 11:47:36 +02:00
Emmanuel Merali
9ba000c54c Revert "Retry delay - selectDB on array"
This reverts commit 3fb643211e.
2013-01-29 11:40:06 +02:00
Emmanuel Merali
3fb643211e Retry delay - selectDB on array
Added the possibility to delay each reconnection attempt, including a
random factor to prevent several or many concurrent connections from
trying to reconnect at the same time.
Added the select command to RedisArray to select a DB on every
connections in one instruction.
2013-01-21 18:10:16 +02:00
Nicolas Favre-Felix
20f555eafb Copy zval in multi/exec/pipe forwarded array calls
* Addresses GitHub issue #262
* Tested successfully with code provided by bug reporter
* array-tests.php passes
2012-10-08 21:58:56 +01:00
Nicolas Favre-Felix
6dc3ad6cb3 Fix RedisArray::_rehash to support closures
* Add "f" parameter in _rehash()
* Call object with new method
* Add rehash test with closure
2012-09-10 00:29:44 +01:00