commit 8262bfa: [Minor] Another try to fix reuseport damage

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Sep 17 22:21:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-09-17 23:15:51 +0100
URL: https://github.com/rspamd/rspamd/commit/8262bfa73f9067ebb7c6d0e2ea7851b5b2496064 (HEAD -> master)

[Minor] Another try to fix reuseport damage

---
 src/libserver/worker_util.c | 5 +++++
 src/rspamd.c                | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 2d40d057c..14394726d 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -985,6 +985,8 @@ rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
 	nfd = ls->fd;
 #endif
 
+#if 0
+	/* This needed merely if we have reuseport for tcp, but for now it is disabled */
 	/* This means that we have an fd with no listening enabled */
 	if (nfd != -1) {
 		if (ls->type == RSPAMD_WORKER_SOCKET_TCP) {
@@ -993,6 +995,7 @@ rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
 			}
 		}
 	}
+#endif
 
 	return true;
 }
@@ -1070,6 +1073,8 @@ rspamd_handle_child_fork (struct rspamd_worker *wrk,
 							strerror (errno));
 				}
 
+				ls->fd = -1;
+
 				cur = g_list_next (cur);
 			}
 		}
diff --git a/src/rspamd.c b/src/rspamd.c
index 6508b4e8c..5e87103eb 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -396,9 +396,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
 	GList *result = NULL;
 	gint fd;
 	guint i;
-	static const int listen_opts = RSPAMD_INET_ADDRESS_LISTEN_ASYNC|
-								   RSPAMD_INET_ADDRESS_LISTEN_REUSEPORT|
-								   RSPAMD_INET_ADDRESS_LISTEN_NOLISTEN;
+	static const int listen_opts = RSPAMD_INET_ADDRESS_LISTEN_ASYNC;
 	struct rspamd_worker_listen_socket *ls;
 
 	g_ptr_array_sort (addrs, rspamd_inet_address_compare_ptr);
@@ -422,7 +420,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
 		if (listen_type & RSPAMD_WORKER_SOCKET_UDP) {
 			fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
 					SOCK_DGRAM,
-					listen_opts, -1);
+					listen_opts | RSPAMD_INET_ADDRESS_LISTEN_REUSEPORT, -1);
 			if (fd != -1) {
 				ls = g_malloc0 (sizeof (*ls));
 				ls->addr = rspamd_inet_address_copy (g_ptr_array_index (addrs, i));


More information about the Commits mailing list