96 Commits

Author SHA1 Message Date
michael-grunder
fd5819c520 Merge branch 'php7-ipv6' into php7 2016-06-02 11:12:40 -07:00
michael-grunder
892f92812e Initialize callbacks in ra_load_array as well 2016-04-14 08:55:55 -07:00
michael-grunder
2887ad1130 Remove debug function 2016-02-15 14:00:55 -08:00
michael-grunder
2b501a48e1 Fixed many memory leaks.
The php7 api changed from previous versions in that there is no
longer the option to "duplicate or not duplicate" a string value
when using the ZVAL_STRING and ZVAL_STRINGL macros.

This means that every time ZVAL_STRING or ZVAL_STRINGL is being
called, one *must* call zval_dtor on that zval or there will be
a leak.

In addition there were several places where the return value from
a zend_call_function passthrough was not being freed, and then
being used again.  Specifically (in the context of RedisArray)
it was when the array was already in MULTI mode, meaning that the
return is a refcounted copy of the Redis object itself, which also
needs to be freed to avoid a leak.

All unit tests passing in debug/release mode with no memory leaks
being reported or any complaining from valgrind.
2016-02-15 13:55:41 -08:00
michael-grunder
9355604cd3 Spaces not tabs 2016-02-14 17:18:03 -08:00
michael-grunder
fe7f81b598 Fix memory leaks 2016-02-14 15:19:15 -08:00
michael-grunder
2a4407f7d9 More IPv6 additions
* Modified RedisArray to support IPv6
* Updated general test suite to take an override host
* Updated make-cluster.sh to take an override host
2016-02-12 18:20:26 -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
Jan-E
4d66e3d4c0 Fix incompatible types 2015-09-09 02:40:38 +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
michael-grunder
fb0597992a Merge remote 2015-05-07 16:30:11 -07:00
michael-grunder
90a7cf4817 Updates to fix rebase issues 2015-05-06 12:12:49 -07:00
michael-grunder
69c6c04eec Added RedisArray and RedisCluster to config.w32 and more win32 fixes
Manually picked from: 6c377eee18
2015-05-05 15:22:40 -07:00
michael-grunder
97c9edc3aa Sorted a memory leak in RedisArray and retabbed unit tests 2015-05-05 15:18:01 -07:00
michael-grunder
0b269cbb72 More RedisCluster fixes
* Properly handle single array as well as variadic arguments for
  things like RedisCluster::del
* Wrapping keys in {} such that Redis and RedisCluster tests can
  use the same methods (avoiding CROSSSLOT).
* Fixed a double-free scenerio in redis_array_impl.c
2015-05-05 15:16:49 -07:00
michael-grunder
9c4de060e6 Fix rehashing memory leaks
The pattern to move a key for various types (strings, sets, zsets,
hashes, etc) used a simple pattern:

1.  Construct the call in order to get all of the keys from the source
2.  Make a pass through call to the source node to get a response
3.  Use the response to make a pass through call to the destination node

The issue, however, was that we were using the same return value variable
for both source and destination nodes, so we would leak the response from
the source node.

Conflicts:
	redis_array_impl.c
2015-05-05 15:13:39 -07:00
michael-grunder
887eff0a9a Fix memory leaks in RedisArray (backport from develop) 2015-05-05 15:13:39 -07:00
michael-grunder
f0f341e90d Remove unused variable 2015-01-30 11:08:07 -08:00
michael-grunder
6dcc950054 Fix rehashing memory leaks
The pattern to move a key for various types (strings, sets, zsets,
hashes, etc) used a simple pattern:

1.  Construct the call in order to get all of the keys from the source
2.  Make a pass through call to the source node to get a response
3.  Use the response to make a pass through call to the destination node

The issue, however, was that we were using the same return value variable
for both source and destination nodes, so we would leak the response from
the source node.
2015-01-29 15:57:17 -08:00
michael-grunder
f37574e959 Fix some simple leaks in RedisArray
* Make sure we always free our allocated key when extracting
* Don't copy z_fun and z_dist twice and only free one
* Free outer array for z_zadd_args
2015-01-29 15:17:18 -08:00
Michael Maclean
9f6edf8ada Iterate over hosts hash table in a safer way 2015-01-28 16:03:24 +00:00
Michael Maclean
a308b81068 Replace calls to zend_hash_quick_find with NULL arguments 2015-01-28 16:03:05 +00:00
michael-grunder
66cdeb6b59 Allow integer connect_timeout in RedisArray
Addresses #520
2014-10-20 12:20:57 -07:00
Anatol Belski
cdd4557f01 fix unreferenced variable warnings 2014-07-01 16:59:41 +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
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
michael-grunder
6194d45dcc Merge branch 'hotfix/ra_type_check' into develop 2014-03-09 11:06:58 -07:00
michael-grunder
0bf1971951 Data type check on redis array host info
RedisArray will segfault if you pass something other than strings
into your array of hosts.  This is invalid input (needs strings here)
but it shouldn't crash php.
2014-03-09 11:05:45 -07:00
michael-grunder
893c15af67 Cleanup merge 2014-02-23 12:24:16 -08:00
Mike
e3403e9588 fix for parsing ini value from string (atol should have been atof) 2014-02-23 11:51:14 -08: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
Nicolas Van Eenaeme
0fd41c2aef Fixed ra->pconnect parameter in ra_make_array
This parameter was ignored and caused pconnect not to work
2013-11-13 11:46:38 -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
eb0bbbafa0 Rollback the automatic resharding distributor
I accidentally pulled this when getting some of the pull requests
integrated (git flow style) for this release.  I like the idea
for sure, but I think it needs more detailed documentation and
further testing.

At the very least, I need to understand it :)
2013-08-31 19:20:34 -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
16185f2e37 Re-add UNIX socket support to RedisArray
Merging the logic from ra-performance branch into feature/ra-performance
2013-08-11 09:01:49 -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
Emmanuel Merali
0ff393bdca Fix poor performance on initial use
Fix poor performance on initial use of easy reshard distributor
mechanism.
2013-07-22 05:29:35 +03:00
Emmanuel Merali
958e062800 Changed distributor to accepts strings
Changed distributor to accept strings as well as longs so that
definitions parsed from parse_ini_files may be used as is
2013-07-22 04:50:11 +03:00
Emmanuel Merali
2f795ed0b4 FIx C99 compliance
FIx C99 compliance
2013-05-26 01:25:27 +03:00
Emmanuel Merali
f4acf122ea Easy resharding distributor
An integrated distributor for easy resharding.
Works on the principle of redistributing keys from 1 shard to 2 shards
evenly.
2013-05-22 06:12:44 +03:00