]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Avoid overriding of GError if Redis is unavailable
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Apr 2018 14:10:59 +0000 (15:10 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Apr 2018 14:10:59 +0000 (15:10 +0100)
src/libstat/backends/redis_backend.c

index 68da6bc89947b573485e1e08ced5fe0e8c692d0f..79fafd15bc5dc2cb58edf53458442066c5390488 100644 (file)
@@ -1040,9 +1040,11 @@ rspamd_redis_timeout (gint fd, short what, gpointer d)
                redisAsyncFree (redis);
        }
 
-       g_set_error (&rt->err, rspamd_redis_stat_quark (), ETIMEDOUT,
-                       "error getting reply from redis server %s: timeout",
-                       rspamd_upstream_name (rt->selected));
+       if (!rt->err) {
+               g_set_error (&rt->err, rspamd_redis_stat_quark (), ETIMEDOUT,
+                               "error getting reply from redis server %s: timeout",
+                               rspamd_upstream_name (rt->selected));
+       }
 }
 
 /* Called when we have connected to the redis server and got stats */
@@ -1091,9 +1093,11 @@ rspamd_redis_connected (redisAsyncContext *c, gpointer r, gpointer priv)
                                rspamd_upstream_name (rt->selected), c->errstr);
                rspamd_upstream_fail (rt->selected);
 
-               g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
-                               "error getting reply from redis server %s: %s",
-                               rspamd_upstream_name (rt->selected), c->errstr);
+               if (!rt->err) {
+                       g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
+                                       "error getting reply from redis server %s: %s",
+                                       rspamd_upstream_name (rt->selected), c->errstr);
+               }
        }
 
 }
@@ -1176,9 +1180,12 @@ rspamd_redis_processed (redisAsyncContext *c, gpointer r, gpointer priv)
                if (rt->redis) {
                        rspamd_upstream_fail (rt->selected);
                }
-               g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
-                               "cannot get values: error getting reply from redis server %s: %s",
-                               rspamd_upstream_name (rt->selected), c->errstr);
+
+               if (!rt->err) {
+                       g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
+                                       "cannot get values: error getting reply from redis server %s: %s",
+                                       rspamd_upstream_name (rt->selected), c->errstr);
+               }
        }
 
        if (rt->has_event) {
@@ -1206,9 +1213,11 @@ rspamd_redis_learned (redisAsyncContext *c, gpointer r, gpointer priv)
                        rspamd_upstream_fail (rt->selected);
                }
 
-               g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
-                               "cannot get learned: error getting reply from redis server %s: %s",
-                               rspamd_upstream_name (rt->selected), c->errstr);
+               if (!rt->err) {
+                       g_set_error (&rt->err, rspamd_redis_stat_quark (), c->err,
+                                       "cannot get learned: error getting reply from redis server %s: %s",
+                                       rspamd_upstream_name (rt->selected), c->errstr);
+               }
        }
 
        if (rt->has_event) {