From: Vsevolod Stakhov Date: Fri, 9 Feb 2018 19:34:29 +0000 (+0000) Subject: [Fix] Fix connecting to a unix socket in rspamadm statconvert X-Git-Tag: 1.7.0~212 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=76afba6b433236cefd224d862fc6dc47bc26a5b6;p=rspamd.git [Fix] Fix connecting to a unix socket in rspamadm statconvert Issue: #1992 Closes: #1992 --- diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 9c5c3fde7..b845b6d49 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -927,8 +927,16 @@ lua_redis_make_request_sync (lua_State *L) if (ret) { double_to_tv (timeout, &tv); - ctx = redisConnectWithTimeout (rspamd_inet_address_to_string (addr->addr), - rspamd_inet_address_get_port (addr->addr), tv); + + if (rspamd_inet_address_get_af (addr->addr) == AF_UNIX) { + ctx = redisConnectUnixWithTimeout ( + rspamd_inet_address_to_string (addr->addr), tv); + } + else { + ctx = redisConnectWithTimeout ( + rspamd_inet_address_to_string (addr->addr), + rspamd_inet_address_get_port (addr->addr), tv); + } if (ip) { rspamd_inet_address_free (ip); @@ -1086,9 +1094,16 @@ lua_redis_connect_sync (lua_State *L) ctx = g_malloc0 (sizeof (struct lua_redis_ctx)); REF_INIT_RETAIN (ctx, lua_redis_dtor); ctx->flags = flags; - ctx->d.sync = redisConnectWithTimeout ( - rspamd_inet_address_to_string (addr->addr), - rspamd_inet_address_get_port (addr->addr), tv); + + if (rspamd_inet_address_get_af (addr->addr) == AF_UNIX) { + ctx->d.sync = redisConnectUnixWithTimeout ( + rspamd_inet_address_to_string (addr->addr), tv); + } + else { + ctx->d.sync = redisConnectWithTimeout ( + rspamd_inet_address_to_string (addr->addr), + rspamd_inet_address_get_port (addr->addr), tv); + } if (ip) { rspamd_inet_address_free (ip);