Skip to content

Commit

Permalink
Increasing read buffers size.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yatsukhnenko committed Apr 5, 2017
1 parent f81694e commit 520e06a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cluster_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ static int cluster_check_response(redisCluster *c, REDIS_REPLY_TYPE *reply_type

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

// Attempt to read the error
Expand Down
14 changes: 7 additions & 7 deletions library.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ PHP_REDIS_API zval *
redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
RedisSock *redis_sock, zval *z_tab)
{
char inbuf[1024];
char inbuf[4096];
int numElems;
size_t len;

Expand Down Expand Up @@ -500,7 +500,7 @@ redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes TSRMLS_DC)
PHP_REDIS_API char *
redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
{
char inbuf[1024];
char inbuf[4096];
size_t len;

*buf_len = 0;
Expand Down Expand Up @@ -1251,7 +1251,7 @@ static int
redis_mbulk_reply_zipped(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
zval *z_tab, int unserialize, int decode)
{
char inbuf[1024];
char inbuf[4096];
int numElems;
size_t len;

Expand Down Expand Up @@ -1688,7 +1688,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
RedisSock *redis_sock, zval *z_tab,
void *ctx)
{
char inbuf[1024];
char inbuf[4096];
int numElems;
size_t len;

Expand Down Expand Up @@ -1731,7 +1731,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
PHP_REDIS_API int
redis_mbulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx)
{
char inbuf[1024];
char inbuf[4096];
int numElems;
size_t len;

Expand Down Expand Up @@ -1808,7 +1808,7 @@ redis_mbulk_reply_loop(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
* keys with their returned values */
PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx)
{
char inbuf[1024], *response;
char inbuf[4096], *response;
int response_len;
int i, numElems;
size_t len;
Expand Down Expand Up @@ -2147,7 +2147,7 @@ redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type,
zval *z_ret TSRMLS_DC)
{
// Buffer to read our single line reply
char inbuf[1024];
char inbuf[4096];
size_t line_size;

/* Attempt to read our single line reply */
Expand Down
2 changes: 1 addition & 1 deletion redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ PHP_REDIS_API int redis_sock_read_multibulk_multi_reply(INTERNAL_FUNCTION_PARAME
RedisSock *redis_sock)
{

char inbuf[1024];
char inbuf[4096];
int numElems;
size_t len;

Expand Down

0 comments on commit 520e06a

Please sign in to comment.