8
8
9
9
extern zend_class_entry * redis_cluster_exception_ce ;
10
10
11
- /* Some debug methods that will go away when we're through with them */
12
-
11
+ /* Debugging methods/
13
12
static void cluster_dump_nodes(redisCluster *c) {
14
13
redisClusterNode **pp, *p;
15
14
@@ -40,7 +39,7 @@ static void cluster_log(char *fmt, ...)
40
39
fprintf(stderr, "%s\n", buffer);
41
40
}
42
41
43
- /* Debug function to dump a clusterReply structure recursively */
42
+ // Debug function to dump a clusterReply structure recursively
44
43
static void dump_reply(clusterReply *reply, int indent) {
45
44
smart_str buf = {0};
46
45
int i;
@@ -87,6 +86,8 @@ static void dump_reply(clusterReply *reply, int indent) {
87
86
efree(buf.c);
88
87
}
89
88
}
89
+ */
90
+
90
91
91
92
/* Recursively free our reply object. If free_data is non-zero we'll also free
92
93
* the payload data (strings) themselves. If not, we just free the structs */
@@ -116,7 +117,7 @@ static void
116
117
cluster_multibulk_resp_recursive (RedisSock * sock , size_t elements ,
117
118
clusterReply * * element , int * err TSRMLS_DC )
118
119
{
119
- size_t idx = 0 ;
120
+ size_t idx = 0 , sz ;
120
121
clusterReply * r ;
121
122
long len ;
122
123
char buf [1024 ];
@@ -137,10 +138,11 @@ cluster_multibulk_resp_recursive(RedisSock *sock, size_t elements,
137
138
switch (r -> type ) {
138
139
case TYPE_ERR :
139
140
case TYPE_LINE :
140
- if (redis_sock_gets (sock ,buf ,sizeof (buf ),& r -> len TSRMLS_CC )< 0 ) {
141
+ if (redis_sock_gets (sock ,buf ,sizeof (buf ),& sz TSRMLS_CC )< 0 ) {
141
142
* err = 1 ;
142
143
return ;
143
144
}
145
+ r -> len = (long long )sz ;
144
146
break ;
145
147
case TYPE_INT :
146
148
r -> integer = len ;
@@ -582,32 +584,6 @@ unsigned short cluster_hash_key_zval(zval *z_key) {
582
584
return cluster_hash_key (kptr , klen );
583
585
}
584
586
585
- static char * * split_str_by_delim (char * str , char * delim , int * len ) {
586
- char * * array , * tok , * tok_buf ;
587
- int size = 16 ;
588
-
589
- * len = 0 ;
590
-
591
- // Initial storage
592
- array = emalloc (size * sizeof (char * ));
593
-
594
- tok = php_strtok_r (str , delim , & tok_buf );
595
-
596
- while (tok ) {
597
- if (size == * len ) {
598
- size *= 2 ;
599
- array = erealloc (array , size * sizeof (char * ));
600
- }
601
-
602
- array [* len ] = tok ;
603
- (* len )++ ;
604
-
605
- tok = php_strtok_r (NULL , delim , & tok_buf );
606
- }
607
-
608
- return array ;
609
- }
610
-
611
587
/* Fisher-Yates shuffle for integer array */
612
588
static void fyshuffle (int * array , size_t len ) {
613
589
int temp , n = len ;
0 commit comments