commit 0eabbc4: [Minor] Use seqpacket for control pipes

Vsevolod Stakhov vsevolod at rspamd.com
Sun Oct 23 17:14:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-10-23 17:57:44 +0100
URL: https://github.com/rspamd/rspamd/commit/0eabbc4492945ddd0a4550fd6aa6a0db7eeae785

[Minor] Use seqpacket for control pipes

---
 src/libserver/rspamd_control.c | 9 +++++++--
 src/libserver/rspamd_control.h | 8 ++------
 src/libserver/worker_util.c    | 7 +++++--
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index ef17ac24f..199efa948 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -908,8 +908,13 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents)
 		r = recvmsg (w->fd, &msg, 0);
 
 		if (r == -1) {
-			msg_err ("cannot read from worker's srv pipe: %s",
-					strerror (errno));
+			if (errno != EAGAIN) {
+				msg_err ("cannot read from worker's srv pipe: %s",
+					strerror(errno));
+			}
+			else {
+				return;
+			}
 		}
 		else if (r == 0) {
 			/*
diff --git a/src/libserver/rspamd_control.h b/src/libserver/rspamd_control.h
index 1b5756022..f6336854c 100644
--- a/src/libserver/rspamd_control.h
+++ b/src/libserver/rspamd_control.h
@@ -20,9 +20,7 @@
 #include "mem_pool.h"
 #include "contrib/libev/ev.h"
 
-#ifdef  __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
 
 struct rspamd_main;
 struct rspamd_worker;
@@ -290,8 +288,6 @@ const gchar *rspamd_control_command_to_string (enum rspamd_control_type cmd);
  */
 void rspamd_pending_control_free (gpointer p);
 
-#ifdef  __cplusplus
-}
-#endif
+G_END_DECLS
 
 #endif
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 6fd2e6164..d8c62d210 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -1228,6 +1228,9 @@ rspamd_handle_main_fork (struct rspamd_worker *wrk,
 #endif
 }
 
+#ifndef SOCK_SEQPACKET
+#define SOCK_SEQPACKET SOCK_DGRAM
+#endif
 struct rspamd_worker *
 rspamd_fork_worker (struct rspamd_main *rspamd_main,
 					struct rspamd_worker_conf *cf,
@@ -1241,12 +1244,12 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
 	/* Starting worker process */
 	wrk = (struct rspamd_worker *) g_malloc0 (sizeof (struct rspamd_worker));
 
-	if (!rspamd_socketpair (wrk->control_pipe, SOCK_DGRAM)) {
+	if (!rspamd_socketpair (wrk->control_pipe, SOCK_SEQPACKET)) {
 		msg_err ("socketpair failure: %s", strerror (errno));
 		rspamd_hard_terminate (rspamd_main);
 	}
 
-	if (!rspamd_socketpair (wrk->srv_pipe, SOCK_DGRAM)) {
+	if (!rspamd_socketpair (wrk->srv_pipe, SOCK_SEQPACKET)) {
 		msg_err ("socketpair failure: %s", strerror (errno));
 		rspamd_hard_terminate (rspamd_main);
 	}


More information about the Commits mailing list