From 08d2fa41695932bfaf199362a0dac27002ffa922 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 29 Oct 2014 15:40:05 +0000 Subject: [PATCH] Fuck ipv6 inventors for ipv6/v4 sockets. --- src/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index e5e2112c6..7f7d82725 100644 --- a/src/main.c +++ b/src/main.c @@ -560,6 +560,15 @@ delay_fork (struct rspamd_worker_conf *cf) set_alarm (SOFT_FORK_TIME); } +static int +af_cmp_workaround (const void *a, const void *b) +{ + rspamd_inet_addr_t *a1 = (rspamd_inet_addr_t *)a, + *a2 = (rspamd_inet_addr_t *)b; + + return a2->af - a1->af; +} + static GList * create_listen_socket (rspamd_inet_addr_t *addrs, guint cnt, gint listen_type) { @@ -567,6 +576,8 @@ create_listen_socket (rspamd_inet_addr_t *addrs, guint cnt, gint listen_type) gint fd; guint i; + /* Fuck morons that have invented ipv6/v4 sockets */ + qsort (addrs, cnt, sizeof (*addrs), af_cmp_workaround); for (i = 0; i < cnt; i ++) { fd = rspamd_inet_address_listen (&addrs[i], listen_type, TRUE); if (fd != -1) { @@ -675,8 +686,7 @@ spawn_workers (struct rspamd_main *rspamd) } else { if (cf->worker->has_socket) { - LL_FOREACH (cf->bind_conf, bcf) - { + LL_FOREACH (cf->bind_conf, bcf) { key = make_listen_key (bcf); if ((p = g_hash_table_lookup (listen_sockets, -- 2.39.5