From: Vsevolod Stakhov Date: Fri, 20 Apr 2018 14:10:59 +0000 (+0100) Subject: [Minor] Avoid overriding of GError if Redis is unavailable X-Git-Tag: 1.7.4~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=efc103598b304ad1292cdf590e36255b8b16c342;p=rspamd.git [Minor] Avoid overriding of GError if Redis is unavailable --- diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index 68da6bc89..79fafd15b 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -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) {