163 Commits

Author SHA1 Message Date
Pavlo Yatsukhnenko 978c307456 Refactor redis_session
Use `redis_sock` to store `auth` and `prefix` for session.
Use `redis_sock_auth` insted of `redis_pool_member_auth`.
2019-07-23 22:16:56 +03:00
Remi Collet 943802272a cleanup TSRMLS_* usage 2019-07-09 15:26:44 +02:00
Pavlo Yatsukhnenko 5ab0e71c76 Don't check lock status in PS_UPDATE_TIMESTAMP_FUNC 2019-02-11 19:58:28 -08:00
Pavlo Yatsukhnenko 50881ddd69 Don't check the number affected keys in PS_UPDATE_TIMESTAMP_FUNC 2019-02-11 19:54:58 -08:00
michael-grunder f9928642b5 PHP 5 is dead, long live PHP 7
This commit removes support for PHP 5 by getting rid of all of our Zend
compatibility layer methods, as well as any call checking against
PHP_MAJOR_VERSION or ZEND_MODULE_API_NO.

Unit tests are all passing for Redis, RedisCluster, and RedisArray but
this should still be considered a work in progress until more testing
can be done.

Addresses issue #1448
2019-01-26 20:57:16 -08:00
Pavlo Yatsukhnenko 3aad9e653b Merge pull request #1494 from phpredis/cluster-auth2
RedisCluster auth
2019-01-21 11:57:35 +02:00
Pavlo Yatsukhnenko 35a2213d30 Merge pull request #1485 from phpredis/consistent-hashing
Implement consistent hashing algorithm for RedisArray
2019-01-21 10:57:40 +02:00
Pavlo Yatsukhnenko c5994f2a42 RedisCluster auth 2019-01-17 23:05:52 +02:00
Marius Meissner 61889cd7ba PHPREDIS-1412: Breaking the lock acquire loop in case of network problems 2018-12-27 10:30:39 +01:00
Pavlo Yatsukhnenko bb32e6f3a0 Implement consistent hashing algorithm for RedisArray 2018-12-22 15:31:51 +02:00
Pavlo Yatsukhnenko c0793e8be4 Remove unused parameter lazy_connect from redis_sock_create 2018-11-21 13:39:50 +02:00
Pavlo Yatsukhnenko 4e2de1581f Fix redis_session
Prevent infinite loop when redis_sock_server_open failed.
Check pool->lock_status.session_key is not NULL in PS_CLOSE_FUNC.
2018-11-07 17:48:58 +02:00
Pavlo Yatsukhnenko 6f7ddd275a Fix coverity scan warnings 2018-11-07 14:03:35 +02:00
Pavlo Yatsukhnenko 071a1d5476 Fix memory leak when aquiring lock 2018-11-07 10:17:30 +02:00
Michael Grunder 92f14b1480 Fix a memory leak when regenerating IDs (#1445)
Make sure we free any existing session lock key if we're going to
update it.  Otherwise we will leak that memory.
2018-11-06 21:20:06 -08:00
Pavlo Yatsukhnenko bfa6170001 Fix scan-build warnings 2018-10-01 09:44:47 +03:00
Michael Grunder 2c9e057236 Streams (#1413)
Streams API
2018-09-29 11:59:01 -07:00
Pavlo Yatsukhnenko 1d99787375 Change connect/reconnect logic
Persistant connections can be closed via close method.
Connection marked as failed only after reconnection attempts.
2018-08-22 09:02:31 +03:00
Pavlo Yatsukhnenko 7171aceaaa Issue #1367
Use `zval_get_long` instead of `Z_STRVAL_P` + `atof` for parsing
timeout and read_timeout params.
2018-07-29 22:57:03 +03:00
Hongbo Liu 1bb7fe48fa Minor refactoring 2018-06-04 09:38:35 +03:00
Hongbo Liu aaaf0f233a Add callbacks validate_sid() & update_timestamp() to session handler
Newer session handler API(PS_MOD_UPDATE_TIMESTAMP) supports 2 more callbacks:

* validate_sid() is used by session.use_strict_mode, which provides better security.
* update_timestamp() is used by session.lazy_write, which can improve performance in some situations.
2018-06-04 09:38:35 +03:00
Pavlo Yatsukhnenko 28ec432247 Issue #1358
Use `cluster_free` in `free_cluster_context` to free cluster object.
Call `cluster_disconnect` before destroying cluster object.
2018-05-31 11:24:28 +03:00
Pavlo Yatsukhnenko e17e65d531 Use zend_string for all lock_status members 2018-03-26 15:36:07 +03:00
Pavlo Yatsukhnenko 07c16e51b0 Apply zend_string API for redis_session_key 2018-03-26 14:24:33 +03:00
Pavlo Yatsukhnenko 5f75efcf95 Extra memory duplication 2018-03-24 21:48:55 +02:00
Pavlo Yatsukhnenko 300c72510c Merge branch 'session-locking' into develop
Conflicts:
	redis_session.c
	tests/RedisTest.php
2018-03-24 17:45:51 +02:00
Pavlo Yatsukhnenko 29edc7db15 Fixes after merge for php5 2018-03-24 14:59:43 +02:00
Pavlo Yatsukhnenko 040ee6421d Fixes after merge 2018-03-24 14:50:47 +02:00
Pavlo Yatsukhnenko e352661eb8 Merge pull request #1312 from SkydiveMarius/session-locking
Session locking: Fix regenerate ID bug (PHP5, proxy handler)
2018-03-24 14:39:51 +02:00
Pavlo Yatsukhnenko fd93e26fc4 Remove redis_pool_new 2018-03-07 19:13:24 +02:00
Pavlo Yatsukhnenko 65fffad365 Refactor redis session
* Use zend_string for storing auth and prefix members
* Allocate redis_session_lock_status structure jointly with redis_pool
* Remove redis_pool_new function
2018-03-06 10:31:58 +02:00
Marius Meissner 0a799af914 PR-1312: Only copy sesseion key if it changed 2018-03-05 15:06:06 +01:00
Marius Meissner 92d90950b6 PR-1312: Refactored code structure of session key check 2018-03-02 11:38:12 +01:00
Marius Meissner caa2902a53 Added check on write operations if session key changed (PHP 5 bug) 2018-03-01 12:29:16 +01:00
Marius Meissner f4cb95ceef Fixed non fully qualified session key on regenerate 2018-03-01 11:06:41 +01:00
michael-grunder a4afe91909 Some style normalization 2018-02-17 09:47:28 -08:00
Andrew Sharpe 2d86a59445 typo 2017-12-26 09:06:13 +10:00
Andrew Sharpe a5fab9dbd7 correct type for php_session_create_id 2017-12-26 08:45:33 +10:00
Andrew Sharpe 70d8c1962d don't refer to sid when it's undefined 2017-12-26 08:11:43 +10:00
Andrew Sharpe a2f9aae206 fixes for PHP 7 2017-12-26 08:01:28 +10:00
Andrew Sharpe 02f4bd318b declare sid in the right scope 2017-12-24 17:15:14 +10:00
Andrew Sharpe eb435546d8 use correct types for php 7 2017-12-24 16:58:17 +10:00
Andrew Sharpe 4530944ed0 Allow session locking to work with session_regenerate_id (see #1267) 2017-12-24 16:04:09 +10:00
Pavlo Yatsukhnenko b566fb44ef PR #1283. Thanks @fmk!
PHP >=7.3.0 uses zend_string to store `php_url` elements.
2017-12-20 17:38:31 +02:00
Pavlo Yatsukhnenko 485db46fec Issue #88
Disallow using empty string as session name.
2017-12-08 13:42:50 +02:00
Pavlo Yatsukhnenko 4b8336f737 Use zend_string for storing auth and prefix members 2017-12-08 11:36:11 +02:00
Pavlo Yatsukhnenko 67babe15d3 Remove trailing spaces 2017-11-17 11:02:41 +02:00
michael-grunder 5a3f76247d Actually change whether we're locked if we can't read the lock key 2017-11-11 11:21:44 -08:00
michael-grunder b63d79958e Refactored session locking logic
* Use a precalculated SHA1 of our lock release script and first
  attempt to EVALSHA the script while falling back to EVAL if that
  fails.  This means that the very first time we attempt to release
  a lock after server restart or script cache will fail but subsequent
  attempts will succeed as Redis will cache the script automatically.

* Reorganized the new locking prototypes by making them static and removing
  them from the header file as they never need to be called from outside
  of redis_session.c anyway.  Did the same for the lock_secret structure
  as we don't need to expose the structure externally.

* Consolidated allocation and deallocation of lock pointers such that our
  redis_pool "constructor" and "desctructor" handle that as well.

* Updating how we release the lock means we no longer need the new REDIS_G
  module globals, so those were removed.

* HOST_NAME_MAX doesn't exist on OSX so added some preprocessor logic around that

Still a WIP as it needs more testing as I'm sure I broke *something* :-)
2017-11-10 13:46:48 -08:00
Marius Meissner e2964295fb PHPREDIS-37: Adjusted code style of php_error_docref() usage 2017-11-02 14:16:02 +01:00