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.6.6~1^2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=400b257a954fbc4f17255541f0413c4e2b79632f;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 c21d69f33..5c906471c 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_slice_alloc0 (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);