Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 520e06a

Browse files
committed
Increasing read buffers size.
When Redis server is running in protected mode it returns error message more than 1024 bites long so first call of redis_sock_gets doesn't read whole message and next call causes "protocol error, got '%c' as reply type byte" exception.
1 parent f81694e commit 520e06a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cluster_library.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ static int cluster_check_response(redisCluster *c, REDIS_REPLY_TYPE *reply_type
10341034

10351035
// In the event of an ERROR, check if it's a MOVED/ASK error
10361036
if(*reply_type == TYPE_ERR) {
1037-
char inbuf[1024];
1037+
char inbuf[4096];
10381038
int moved;
10391039

10401040
// Attempt to read the error

library.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ PHP_REDIS_API zval *
433433
redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
434434
RedisSock *redis_sock, zval *z_tab)
435435
{
436-
char inbuf[1024];
436+
char inbuf[4096];
437437
int numElems;
438438
size_t len;
439439

@@ -500,7 +500,7 @@ redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes TSRMLS_DC)
500500
PHP_REDIS_API char *
501501
redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
502502
{
503-
char inbuf[1024];
503+
char inbuf[4096];
504504
size_t len;
505505

506506
*buf_len = 0;
@@ -1251,7 +1251,7 @@ static int
12511251
redis_mbulk_reply_zipped(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
12521252
zval *z_tab, int unserialize, int decode)
12531253
{
1254-
char inbuf[1024];
1254+
char inbuf[4096];
12551255
int numElems;
12561256
size_t len;
12571257

@@ -1688,7 +1688,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
16881688
RedisSock *redis_sock, zval *z_tab,
16891689
void *ctx)
16901690
{
1691-
char inbuf[1024];
1691+
char inbuf[4096];
16921692
int numElems;
16931693
size_t len;
16941694

@@ -1731,7 +1731,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
17311731
PHP_REDIS_API int
17321732
redis_mbulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx)
17331733
{
1734-
char inbuf[1024];
1734+
char inbuf[4096];
17351735
int numElems;
17361736
size_t len;
17371737

@@ -1808,7 +1808,7 @@ redis_mbulk_reply_loop(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
18081808
* keys with their returned values */
18091809
PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx)
18101810
{
1811-
char inbuf[1024], *response;
1811+
char inbuf[4096], *response;
18121812
int response_len;
18131813
int i, numElems;
18141814
size_t len;
@@ -2147,7 +2147,7 @@ redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type,
21472147
zval *z_ret TSRMLS_DC)
21482148
{
21492149
// Buffer to read our single line reply
2150-
char inbuf[1024];
2150+
char inbuf[4096];
21512151
size_t line_size;
21522152

21532153
/* Attempt to read our single line reply */

redis.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_multi_reply(INTERNAL_FUNCTION_PARAME
23242324
RedisSock *redis_sock)
23252325
{
23262326

2327-
char inbuf[1024];
2327+
char inbuf[4096];
23282328
int numElems;
23292329
size_t len;
23302330

0 commit comments

Comments
 (0)