Browse code

Merge 715580c6573d4291005b81c670be9b667787bcc1 into cc32abd91888f3978708eddc88c4409ef5a6b122

FredWH authored on 27/07/2021 13:54:52 • GitHub committed on 27/07/2021 13:54:52
Showing 1 changed files
... ...
@@ -305,7 +305,8 @@ void *db_redis_command_argv(km_redis_con_t *con, redis_key_t *query) {
305 305
     LM_DBG("query has %d args\n", argc);
306 306
 
307 307
     redisReply *reply = redisCommandArgv(con->con, argc, (const char**)argv, NULL);
308
-    if (con->con->err == REDIS_ERR_EOF) {
308
+    if (con->con->err != REDIS_OK) {
309
+        LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n", con->con->err, con->con->errstr);
309 310
         if (db_redis_connect(con) != 0) {
310 311
             LM_ERR("Failed to reconnect to redis db\n");
311 312
             pkg_free(argv);
... ...
@@ -344,7 +345,8 @@ int db_redis_append_command_argv(km_redis_con_t *con, redis_key_t *query, int qu
344 345
     // this should actually never happen, because if all replies
345 346
     // are properly consumed for the previous command, it won't send
346 347
     // out a new query until redisGetReply is called
347
-    if (con->con->err == REDIS_ERR_EOF) {
348
+    if (con->con->err != REDIS_OK) {
349
+        LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n", con->con->err, con->con->errstr);
348 350
         if (db_redis_connect(con) != 0) {
349 351
             LM_ERR("Failed to reconnect to redis db\n");
350 352
             pkg_free(argv);
... ...
@@ -374,8 +376,8 @@ int db_redis_get_reply(km_redis_con_t *con, void **reply) {
374 376
 
375 377
     *reply = NULL;
376 378
     ret = redisGetReply(con->con, reply);
377
-    if (con->con->err == REDIS_ERR_EOF) {
378
-        LM_DBG("redis connection is gone, try reconnect\n");
379
+    if (con->con->err != REDIS_OK) {
380
+        LM_DBG("redis connection is gone, try reconnect. (%d:%s)\n", con->con->err, con->con->errstr);
379 381
         con->append_counter = 0;
380 382
         if (db_redis_connect(con) != 0) {
381 383
             LM_ERR("Failed to reconnect to redis db\n");
... ...
@@ -396,7 +398,7 @@ int db_redis_get_reply(km_redis_con_t *con, void **reply) {
396 398
             db_redis_key_free(&query);
397 399
         }
398 400
         ret = redisGetReply(con->con, reply);
399
-        if (con->con->err != REDIS_ERR_EOF) {
401
+        if (con->con->err == REDIS_OK) {
400 402
             con->append_counter--;
401 403
         }
402 404
     } else {