]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use seqpacket for control pipes
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 23 Oct 2022 16:57:44 +0000 (17:57 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 23 Oct 2022 16:57:44 +0000 (17:57 +0100)
src/libserver/rspamd_control.c
src/libserver/rspamd_control.h
src/libserver/worker_util.c

index ef17ac24f78c5c9a497f3d70ee729547931d9d47..199efa948628e4af5fef9192396c5b49fd2cba7d 100644 (file)
@@ -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) {
                        /*
index 1b57560222770ae209b3a76cd0f7a463bd19da6d..f6336854cf5121330e7561dacbdde4796276a9e1 100644 (file)
@@ -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
index 6fd2e6164531837d52eaad558241521155641456..d8c62d2100a70d5056e729e7f421cb6f28071288 100644 (file)
@@ -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);
        }