Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f276dc

Browse files
Find our callback by pattern with PSUBSCRIBE
* Use the pattern Redis provides us not the channel, if this isa wildcard based `PSUBSCRIBE` payload.* Don't test whether our slots match in `SSUBSCRIBE` when not in cluster mode.Fixes#2395
1 parentf4c2ac2 commit2f276dc

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

‎library.c‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS,
545545
/* Multibulk response, {[pattern], type, channel, payload } */
546546
while (redis_sock->subs[i]) {
547547
zvalz_ret,z_args[4],*z_type,*z_chan,*z_pat=NULL,*z_data;
548-
HashTable*ht_tab;
549548
inttab_idx=1,is_pmsg=0;
549+
HashTable*ht_tab;
550+
zend_string*zs;
550551

551552
ZVAL_NULL(&z_resp);
552553
if (!redis_sock_read_multibulk_reply_zval(redis_sock,&z_resp)) {
@@ -573,22 +574,26 @@ PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS,
573574
}
574575

575576
// Extract pattern if it's a pmessage
576-
if(is_pmsg) {
577-
if ((z_pat=zend_hash_index_find(ht_tab,tab_idx++))==NULL) {
577+
if (is_pmsg) {
578+
z_pat=zend_hash_index_find(ht_tab,tab_idx++);
579+
if (z_pat==NULL||Z_TYPE_P(z_pat)!=IS_STRING)
578580
gotofailure;
579-
}
580581
}
581582

582-
// Extract channel and data
583-
if ((z_chan=zend_hash_index_find(ht_tab,tab_idx++))==NULL||
584-
(z_data=zend_hash_index_find(ht_tab,tab_idx++))==NULL
585-
) {
583+
/* Extract channel */
584+
z_chan=zend_hash_index_find(ht_tab,tab_idx++);
585+
if (z_chan==NULL||Z_TYPE_P(z_chan)!=IS_STRING)
586586
gotofailure;
587-
}
588587

589-
if ((cb=zend_hash_str_find_ptr(redis_sock->subs[i],Z_STRVAL_P(z_chan),Z_STRLEN_P(z_chan)))==NULL) {
588+
/* Finally, extract data */
589+
z_data=zend_hash_index_find(ht_tab,tab_idx++);
590+
if (z_data==NULL)
591+
gotofailure;
592+
593+
/* Find our callback, either by channel or pattern string */
594+
zs=z_pat!=NULL ?Z_STR_P(z_pat) :Z_STR_P(z_chan);
595+
if ((cb=zend_hash_find_ptr(redis_sock->subs[i],zs))==NULL)
590596
gotofailure;
591-
}
592597

593598
// Different args for SUBSCRIBE and PSUBSCRIBE
594599
z_args[0]=*getThis();

‎redis_commands.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ int redis_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
15801580
ZEND_HASH_FOREACH_VAL(ht_chan,z_chan) {
15811581
redis_cmd_append_sstr_key_zval(&cmdstr,z_chan,redis_sock,slot ?&s2 :NULL);
15821582

1583-
if (shardslot!=REDIS_CLUSTER_SLOTS&&s2!=shardslot) {
1583+
if (slot&& (shardslot!=REDIS_CLUSTER_SLOTS&&s2!=shardslot)) {
15841584
php_error_docref(NULL,E_WARNING,"All shard channels needs to belong to a single slot");
15851585
smart_string_free(&cmdstr);
15861586
efree(sctx);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp