From abb862d2f50f7f3059d68ef4028685566f865aa7 Mon Sep 17 00:00:00 2001 From: Marius Meissner Date: Mon, 30 Oct 2017 11:28:33 +0100 Subject: PHPREDIS-37: Add locking functionality --- php_redis.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'php_redis.h') diff --git a/php_redis.h b/php_redis.h index 895ad710..930346ad 100644 --- a/php_redis.h +++ b/php_redis.h @@ -260,9 +260,17 @@ PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop( INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, int numElems); -#ifndef _MSC_VER ZEND_BEGIN_MODULE_GLOBALS(redis) + int lock_release_lua_script_uploaded; + char lock_release_lua_script_hash[41]; ZEND_END_MODULE_GLOBALS(redis) + +ZEND_EXTERN_MODULE_GLOBALS(redis); + +#ifdef ZTS +#define REDIS_G(v) TSRMG(redis_globals_id, zend_redis_globals *, v) +#else +#define REDIS_G(v) (redis_globals.v) #endif extern zend_module_entry redis_module_entry; -- cgit v1.2.3 From c8ca74d4137fd0e1b0fdd20ac1865660324950e4 Mon Sep 17 00:00:00 2001 From: Marius Meissner Date: Thu, 2 Nov 2017 12:41:54 +0100 Subject: PHPREDIS-37: Converted global lock_release_lua_script_hash to pointer and use estrdup for filling --- php_redis.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php_redis.h') diff --git a/php_redis.h b/php_redis.h index 930346ad..9d47e058 100644 --- a/php_redis.h +++ b/php_redis.h @@ -262,7 +262,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop( ZEND_BEGIN_MODULE_GLOBALS(redis) int lock_release_lua_script_uploaded; - char lock_release_lua_script_hash[41]; + char *lock_release_lua_script_hash; ZEND_END_MODULE_GLOBALS(redis) ZEND_EXTERN_MODULE_GLOBALS(redis); -- cgit v1.2.3 From b63d79958e0f6b5abc6eaa6f720b4bfb17eb2e8f Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Fri, 10 Nov 2017 13:46:48 -0800 Subject: 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* :-) --- php_redis.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'php_redis.h') diff --git a/php_redis.h b/php_redis.h index 9d47e058..d3272465 100644 --- a/php_redis.h +++ b/php_redis.h @@ -260,19 +260,6 @@ PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop( INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, int numElems); -ZEND_BEGIN_MODULE_GLOBALS(redis) - int lock_release_lua_script_uploaded; - char *lock_release_lua_script_hash; -ZEND_END_MODULE_GLOBALS(redis) - -ZEND_EXTERN_MODULE_GLOBALS(redis); - -#ifdef ZTS -#define REDIS_G(v) TSRMG(redis_globals_id, zend_redis_globals *, v) -#else -#define REDIS_G(v) (redis_globals.v) -#endif - extern zend_module_entry redis_module_entry; #define redis_module_ptr &redis_module_entry -- cgit v1.2.3