@@ -112,23 +112,15 @@ static int resend_auth(RedisSock *redis_sock TSRMLS_DC) {
112
112
* 2) AUTH
113
113
* 3) LOADING
114
114
*/
115
- static void redis_error_throw (char * err , size_t err_len TSRMLS_DC ) {
116
- /* Handle stale data error (slave syncing with master) */
117
- if (err_len == sizeof (REDIS_ERR_SYNC_MSG ) - 1 &&
118
- !memcmp (err ,REDIS_ERR_SYNC_KW ,sizeof (REDIS_ERR_SYNC_KW )- 1 ))
119
- {
120
- zend_throw_exception (redis_exception_ce ,
121
- "SYNC with master in progress or master down!" , 0 TSRMLS_CC );
122
- } else if (err_len == sizeof (REDIS_ERR_LOADING_MSG ) - 1 &&
123
- !memcmp (err ,REDIS_ERR_LOADING_KW ,sizeof (REDIS_ERR_LOADING_KW )- 1 ))
124
- {
125
- zend_throw_exception (redis_exception_ce ,
126
- "Redis is LOADING the dataset" , 0 TSRMLS_CC );
127
- } else if (err_len == sizeof (REDIS_ERR_AUTH_MSG ) - 1 &&
128
- !memcmp (err ,REDIS_ERR_AUTH_KW ,sizeof (REDIS_ERR_AUTH_KW )- 1 ))
129
- {
130
- zend_throw_exception (redis_exception_ce ,
131
- "Failed to AUTH connection" , 0 TSRMLS_CC );
115
+ static void
116
+ redis_error_throw (RedisSock * redis_sock TSRMLS_DC )
117
+ {
118
+ if (redis_sock != NULL && redis_sock -> err != NULL &&
119
+ memcmp (redis_sock -> err , "ERR" , sizeof ("ERR" ) - 1 ) != 0 &&
120
+ memcmp (redis_sock -> err , "NOSCRIPT" , sizeof ("NOSCRIPT" ) - 1 ) != 0 &&
121
+ memcmp (redis_sock -> err , "WRONGTYPE" , sizeof ("WRONGTYPE" ) - 1 ) != 0
122
+ ) {
123
+ zend_throw_exception (redis_exception_ce , redis_sock -> err , 0 TSRMLS_CC );
132
124
}
133
125
}
134
126
@@ -513,13 +505,8 @@ redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
513
505
redis_sock_set_err (redis_sock , inbuf + 1 , len );
514
506
515
507
/* Filter our ERROR through the few that should actually throw */
516
- redis_error_throw (inbuf + 1 , len TSRMLS_CC );
508
+ redis_error_throw (redis_sock TSRMLS_CC ) ;
517
509
518
- /* Handle stale data error */
519
- if (memcmp (inbuf + 1 , "-ERR SYNC " , 10 ) == 0 ) {
520
- zend_throw_exception (redis_exception_ce ,
521
- "SYNC with master in progress" , 0 TSRMLS_CC );
522
- }
523
510
return NULL ;
524
511
case '$' :
525
512
* buf_len = atoi (inbuf + 1 );
@@ -2159,12 +2146,12 @@ redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type,
2159
2146
// If this is an error response, check if it is a SYNC error, and throw in
2160
2147
// that case
2161
2148
if (reply_type == TYPE_ERR ) {
2162
- /* Handle throwable errors */
2163
- redis_error_throw (inbuf , line_size TSRMLS_CC );
2164
-
2165
2149
/* Set our last error */
2166
2150
redis_sock_set_err (redis_sock , inbuf , line_size );
2167
2151
2152
+ /* Handle throwable errors */
2153
+ redis_error_throw (redis_sock TSRMLS_CC );
2154
+
2168
2155
/* Set our response to FALSE */
2169
2156
ZVAL_FALSE (z_ret );
2170
2157
} else {
0 commit comments