aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-30 12:49:31 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-30 12:49:31 +0000
commit3a98d054f54cd3f558dc3596fdde46d7c456d0fc (patch)
tree0bd8a31e2bf05fc3f009643ea3d85276f112a749 /src
parent3e8d0156b8549c38be5c934686c86e9133420e3a (diff)
downloadrspamd-3a98d054f54cd3f558dc3596fdde46d7c456d0fc.tar.gz
rspamd-3a98d054f54cd3f558dc3596fdde46d7c456d0fc.zip
[Minor] Add support for unix connections for redis stats backend
Diffstat (limited to 'src')
-rw-r--r--src/libstat/backends/redis_backend.c31
-rw-r--r--src/libstat/learn_cache/redis_cache.c11
2 files changed, 34 insertions, 8 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 2018f303a..b747fd75f 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -650,8 +650,15 @@ rspamd_redis_async_stat_cb (struct rspamd_stat_async_elt *elt, gpointer d)
g_assert (cbdata->selected != NULL);
addr = rspamd_upstream_addr (cbdata->selected);
g_assert (addr != NULL);
- cbdata->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
- rspamd_inet_address_get_port (addr));
+
+ if (rspamd_inet_address_get_af (addr) == AF_UNIX) {
+ cbdata->redis = redisAsyncConnectUnix (rspamd_inet_address_to_string (addr));
+ }
+ else {
+ cbdata->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
+ rspamd_inet_address_get_port (addr));
+ }
+
g_assert (cbdata->redis != NULL);
redisLibeventAttach (cbdata->redis, redis_elt->ev_base);
@@ -1143,8 +1150,14 @@ rspamd_redis_runtime (struct rspamd_task *task,
addr = rspamd_upstream_addr (up);
g_assert (addr != NULL);
- rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
- rspamd_inet_address_get_port (addr));
+
+ if (rspamd_inet_address_get_af (addr) == AF_UNIX) {
+ rt->redis = redisAsyncConnectUnix (rspamd_inet_address_to_string (addr));
+ }
+ else {
+ rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
+ rspamd_inet_address_get_port (addr));
+ }
if (rt->redis == NULL) {
msg_err_task ("cannot connect redis");
@@ -1270,8 +1283,14 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens,
addr = rspamd_upstream_addr (up);
g_assert (addr != NULL);
- rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
- rspamd_inet_address_get_port (addr));
+ if (rspamd_inet_address_get_af (addr) == AF_UNIX) {
+ rt->redis = redisAsyncConnectUnix (rspamd_inet_address_to_string (addr));
+ }
+ else {
+ rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
+ rspamd_inet_address_get_port (addr));
+ }
+
g_assert (rt->redis != NULL);
redisLibeventAttach (rt->redis, task->ev_base);
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 21f35a563..cc6e66469 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -398,8 +398,15 @@ rspamd_stat_cache_redis_runtime (struct rspamd_task *task,
addr = rspamd_upstream_addr (up);
g_assert (addr != NULL);
- rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
- rspamd_inet_address_get_port (addr));
+
+ if (rspamd_inet_address_get_af (addr) == AF_UNIX) {
+ rt->redis = redisAsyncConnectUnix (rspamd_inet_address_to_string (addr));
+ }
+ else {
+ rt->redis = redisAsyncConnect (rspamd_inet_address_to_string (addr),
+ rspamd_inet_address_get_port (addr));
+ }
+
g_assert (rt->redis != NULL);
redisLibeventAttach (rt->redis, task->ev_base);