aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-09 15:49:29 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-09 15:49:29 +0000
commit288304789907e4d8bbb5b71dc627c2a5aad2f935 (patch)
treef5e36ea28c70f7fdf7d09932042be97f13341436 /src/main.c
parent49b2e92d1add1b3746cc71124c1939b6a3288f94 (diff)
downloadrspamd-288304789907e4d8bbb5b71dc627c2a5aad2f935.tar.gz
rspamd-288304789907e4d8bbb5b71dc627c2a5aad2f935.zip
Fix simultaneous bind to ipv6 and ipv6 sockets.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 1765a47b1..1cb641cda 100644
--- a/src/main.c
+++ b/src/main.c
@@ -527,7 +527,7 @@ delay_fork (struct worker_conf *cf)
}
static GList *
-create_listen_socket (const gchar *addr, gint port, gint family, gint listen_type)
+create_listen_socket (const gchar *addr, gint port, gint listen_type)
{
gint listen_sock = -1;
GList *result, *cur;
@@ -565,12 +565,13 @@ fork_delayed (struct rspamd_main *rspamd)
}
static inline uintptr_t
-make_listen_key (const gchar *addr, gint port, gint family)
+make_listen_key (gint ai, const gchar *addr, gint port)
{
uintptr_t res = 0;
res = murmur32_hash (addr, strlen (addr));
- res ^= murmur32_hash ((guchar *)&port, sizeof (gint));
+ res += murmur32_hash ((guchar *)&ai, sizeof (gint));
+ res += murmur32_hash ((guchar *)&port, sizeof (gint));
return res;
}
@@ -580,7 +581,7 @@ spawn_workers (struct rspamd_main *rspamd)
{
GList *cur, *ls;
struct worker_conf *cf;
- gint i;
+ gint i, key;
gpointer p;
struct rspamd_worker_bind_conf *bcf;
@@ -595,24 +596,21 @@ spawn_workers (struct rspamd_main *rspamd)
else {
if (cf->worker->has_socket) {
LL_FOREACH (cf->bind_conf, bcf) {
- if ((p = g_hash_table_lookup (listen_sockets, GINT_TO_POINTER (
- make_listen_key (bcf->bind_host, bcf->bind_port, bcf->is_unix)))) == NULL) {
+ key = make_listen_key (bcf->ai, bcf->bind_host, bcf->bind_port);
+ if ((p = g_hash_table_lookup (listen_sockets, GINT_TO_POINTER (key))) == NULL) {
/* Create listen socket */
ls = create_listen_socket (bcf->bind_host, bcf->bind_port,
- bcf->is_unix ? AF_UNIX : AF_INET,
cf->worker->listen_type);
if (ls == NULL) {
exit (-errno);
}
- g_hash_table_insert (listen_sockets, GINT_TO_POINTER (
- make_listen_key (bcf->bind_host, bcf->bind_port, bcf->is_unix)),
- ls);
+ g_hash_table_insert (listen_sockets, GINT_TO_POINTER (key), ls);
}
else {
/* We had socket for this type of worker */
ls = p;
}
- cf->listen_socks = ls;
+ cf->listen_socks = g_list_concat (cf->listen_socks, ls);
}
}