]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fuck ipv6 inventors for ipv6/v4 sockets.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Oct 2014 15:40:05 +0000 (15:40 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Oct 2014 15:40:05 +0000 (15:40 +0000)
src/main.c

index e5e2112c68abc7910b37c80c436fc3df294724d3..7f7d8272589a9f2723ee4d61cd67dbc8659e8b65 100644 (file)
@@ -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,