diff options
-rw-r--r-- | cluster_library.c | 2 | ||||
-rw-r--r-- | cluster_library.h | 4 | ||||
-rw-r--r-- | library.c | 12 | ||||
-rw-r--r-- | library.h | 2 |
4 files changed, 10 insertions, 10 deletions
diff --git a/cluster_library.c b/cluster_library.c index 0dee495d..8ebc8760 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -1161,7 +1161,7 @@ static int cluster_check_response(redisCluster *c, REDIS_REPLY_TYPE *reply_type) CLUSTER_CLEAR_ERROR(c); CLUSTER_CLEAR_REPLY(c); - if (-1 == redis_check_eof(c->cmd_sock, 1) || + if (-1 == redis_check_eof(c->cmd_sock, 1, 1) || EOF == (*reply_type = php_stream_getc(c->cmd_sock->stream))) { return -1; diff --git a/cluster_library.h b/cluster_library.h index 6e450705..811c435d 100644 --- a/cluster_library.h +++ b/cluster_library.h @@ -62,12 +62,12 @@ /* Protected sending of data down the wire to a RedisSock->stream */ #define CLUSTER_SEND_PAYLOAD(sock, buf, len) \ - (sock && !redis_sock_server_open(sock) && sock->stream && !redis_check_eof(sock, 1 ) && \ + (sock && !redis_sock_server_open(sock) && sock->stream && !redis_check_eof(sock, 0, 1) && \ php_stream_write(sock->stream, buf, len)==len) /* Macro to read our reply type character */ #define CLUSTER_VALIDATE_REPLY_TYPE(sock, type) \ - (redis_check_eof(sock, 1) == 0 && \ + (redis_check_eof(sock, 1, 1) == 0 && \ (php_stream_getc(sock->stream) == type)) /* Reset our last single line reply buffer and length */ @@ -287,7 +287,7 @@ redis_error_throw(RedisSock *redis_sock) } PHP_REDIS_API int -redis_check_eof(RedisSock *redis_sock, int no_throw) +redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw) { unsigned int retry_index; char *errmsg; @@ -322,7 +322,7 @@ redis_check_eof(RedisSock *redis_sock, int no_throw) } else { errmsg = "Connection lost"; redis_backoff_reset(&redis_sock->backoff); - for (retry_index = 0; retry_index < redis_sock->max_retries; ++retry_index) { + for (retry_index = 0; !no_retry && retry_index < redis_sock->max_retries; ++retry_index) { /* close existing stream before reconnecting */ if (redis_sock->stream) { redis_sock_disconnect(redis_sock, 1); @@ -592,7 +592,7 @@ redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes) char *reply; size_t got; - if (-1 == bytes || -1 == redis_check_eof(redis_sock, 0)) { + if (-1 == bytes || -1 == redis_check_eof(redis_sock, 1, 0)) { return NULL; } @@ -2865,7 +2865,7 @@ failure: PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz) { - if (redis_check_eof(redis_sock, 0) == 0 && + if (redis_check_eof(redis_sock, 0, 0) == 0 && php_stream_write(redis_sock->stream, cmd, sz) == sz ) { return sz; @@ -3343,7 +3343,7 @@ redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t *line_size) { // Handle EOF - if(-1 == redis_check_eof(redis_sock, 0)) { + if(-1 == redis_check_eof(redis_sock, 1, 0)) { return -1; } @@ -3376,7 +3376,7 @@ redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type, long *reply_info) { // Make sure we haven't lost the connection, even trying to reconnect - if(-1 == redis_check_eof(redis_sock, 0)) { + if(-1 == redis_check_eof(redis_sock, 1, 0)) { // Failure *reply_type = EOF; return -1; @@ -111,7 +111,7 @@ PHP_REDIS_API int redis_unsubscribe_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz); -PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, int no_throw); +PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw); PHP_REDIS_API RedisSock *redis_sock_get(zval *id, int nothrow); PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock); PHP_REDIS_API void redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len); |