From 0d218b76d12633a36832794bb8eb1bd840d0cc1a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 10 Jun 2020 13:11:52 +0100 Subject: [PATCH] [Minor] Add shutdown calls to specify one direction for the pipe --- src/fuzzy_storage.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 588e4a1378..99e79e098b 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -2165,11 +2165,17 @@ fuzzy_peer_rep (struct rspamd_worker *worker, cur = g_list_next (cur); } - if (worker->index == 0 && ctx->peer_fd != -1) { - /* Listen for peer requests */ - ctx->peer_ev.data = ctx; - ev_io_init (&ctx->peer_ev, rspamd_fuzzy_peer_io, ctx->peer_fd, EV_READ); - ev_io_start (ctx->event_loop, &ctx->peer_ev); + if (ctx->peer_fd != -1) { + if (worker->index == 0) { + /* Listen for peer requests */ + shutdown (ctx->peer_fd, SHUT_WR); + ctx->peer_ev.data = ctx; + ev_io_init (&ctx->peer_ev, rspamd_fuzzy_peer_io, ctx->peer_fd, EV_READ); + ev_io_start (ctx->event_loop, &ctx->peer_ev); + } + else { + shutdown (ctx->peer_fd, SHUT_RD); + } } }