@@ -846,7 +846,7 @@ PHP_REDIS_API void cluster_free(redisCluster *c) {
846
846
if (c -> err ) efree (c -> err );
847
847
848
848
/* Free structure itself */
849
- efree (c );
849
+ efree (c );
850
850
}
851
851
852
852
/* Initialize seeds */
@@ -1089,7 +1089,7 @@ static int cluster_dist_write(redisCluster *c, const char *cmd, size_t sz,
1089
1089
for (i = 0 ; i < count ; i ++ ) {
1090
1090
/* Skip if this is the master node and we don't want to query that */
1091
1091
if (nomaster && nodes [i ] == 0 )
1092
- continue ;
1092
+ continue ;
1093
1093
1094
1094
/* Get the slave for this index */
1095
1095
redis_sock = cluster_slot_sock (c , c -> cmd_slot , nodes [i ]);
@@ -1240,6 +1240,8 @@ static redisClusterNode *cluster_find_node(redisCluster *c, const char *host,
1240
1240
* the slot where data was moved, update our node mapping */
1241
1241
static void cluster_update_slot (redisCluster * c TSRMLS_DC ) {
1242
1242
redisClusterNode * node ;
1243
+ char key [1024 ];
1244
+ size_t klen ;
1243
1245
1244
1246
/* Do we already have the new slot mapped */
1245
1247
if (c -> master [c -> redir_slot ]) {
@@ -1259,6 +1261,11 @@ static void cluster_update_slot(redisCluster *c TSRMLS_DC) {
1259
1261
node = cluster_node_create (c , c -> redir_host , c -> redir_host_len ,
1260
1262
c -> redir_port , c -> redir_slot , 0 );
1261
1263
1264
+ /* Our node is new, so keep track of it for cleanup */
1265
+ klen = snprintf (key ,sizeof (key ),"%s:%ld" ,c -> redir_host ,c -> redir_port );
1266
+ zend_hash_update (c -> nodes , key , klen + 1 , (void * )& node ,
1267
+ sizeof (redisClusterNode * ), NULL );
1268
+
1262
1269
/* Now point our slot at the node */
1263
1270
c -> master [c -> redir_slot ] = node ;
1264
1271
}
@@ -1418,7 +1425,10 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
1418
1425
}
1419
1426
1420
1427
/* Update mapping if the data has MOVED */
1421
- if (c -> redir_type == REDIR_MOVED ) cluster_update_slot (c TSRMLS_CC );
1428
+ if (c -> redir_type == REDIR_MOVED ) {
1429
+ cluster_update_slot (c TSRMLS_CC );
1430
+ c -> cmd_sock = SLOT_SOCK (c , slot );
1431
+ }
1422
1432
}
1423
1433
1424
1434
/* Figure out if we've timed out trying to read or write the data */
@@ -2302,7 +2312,7 @@ int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result,
2302
2312
while (count -- ) {
2303
2313
/* Read our line */
2304
2314
line = redis_sock_read (redis_sock , & line_len TSRMLS_CC );
2305
-
2315
+
2306
2316
if (line != NULL ) {
2307
2317
zval * z = NULL ;
2308
2318
if (redis_unserialize (redis_sock , line , line_len , & z TSRMLS_CC )== 1 ) {
0 commit comments