6161/* Check if a response is the Redis +OK status response */
6262#define IS_REDIS_OK (r , len ) (r != NULL && len == 3 && !memcmp(r, "+OK", 3))
6363
64- #if (PHP_MAJOR_VERSION < 7 )
6564ps_module ps_mod_redis = {
65+ #if (PHP_MAJOR_VERSION < 7 )
6666 PS_MOD_SID (redis )
67- };
6867#else
69- ps_module ps_mod_redis = {
7068 PS_MOD_UPDATE_TIMESTAMP (redis )
71- };
7269#endif
70+ };
7371
7472ps_module ps_mod_redis_cluster = {
7573 PS_MOD (rediscluster )
@@ -650,13 +648,9 @@ PS_VALIDATE_SID_FUNC(redis)
650648{
651649 char * cmd , * response ;
652650 int cmd_len , response_len ;
653- #if (PHP_MAJOR_VERSION < 7 )
654- const char * skey = key ;
655- size_t skeylen = strlen (key );
656- #else
651+
657652 const char * skey = ZSTR_VAL (key );
658653 size_t skeylen = ZSTR_LEN (key );
659- #endif
660654
661655 if (!skeylen ) return FAILURE ;
662656
@@ -691,27 +685,25 @@ PS_VALIDATE_SID_FUNC(redis)
691685 }
692686}
693687/* }}} */
688+ #endif
694689
690+ #if (PHP_MAJOR_VERSION >= 7 )
695691/* {{{ PS_UPDATE_TIMESTAMP_FUNC
696692 */
697693PS_UPDATE_TIMESTAMP_FUNC (redis )
698694{
699695 char * cmd , * response ;
700696 int cmd_len , response_len ;
701- #if (PHP_MAJOR_VERSION < 7 )
702- const char * skey = key , * sval = val ;
703- size_t skeylen = strlen (key ), svallen = vallen ;
704- #else
697+
705698 const char * skey = ZSTR_VAL (key ), * sval = ZSTR_VAL (val );
706699 size_t skeylen = ZSTR_LEN (key ), svallen = ZSTR_LEN (val );
707- #endif
708700
709701 if (!skeylen ) return FAILURE ;
710702
711703 redis_pool * pool = PS_GET_MOD_DATA ();
712704 redis_pool_member * rpm = redis_pool_get_sock (pool , skey TSRMLS_CC );
713705 RedisSock * redis_sock = rpm ? rpm -> redis_sock : NULL ;
714- if (!redis_sock ) {
706+ if (!redis_sock || ! write_allowed ( redis_sock , & pool -> lock_status TSRMLS_CC ) ) {
715707 return FAILURE ;
716708 }
717709
@@ -720,7 +712,7 @@ PS_UPDATE_TIMESTAMP_FUNC(redis)
720712 cmd_len = REDIS_SPPRINTF (& cmd , "EXPIRE" , "Sd" , session , INI_INT ("session.gc_maxlifetime" ));
721713 zend_string_release (session );
722714
723- if (! write_allowed ( redis_sock , & pool -> lock_status TSRMLS_CC ) || redis_sock_write (redis_sock , cmd , cmd_len TSRMLS_CC ) < 0 ) {
715+ if (redis_sock_write (redis_sock , cmd , cmd_len TSRMLS_CC ) < 0 ) {
724716 efree (cmd );
725717 return FAILURE ;
726718 }
0 commit comments