From 68a12a3b0ead64fa9c57141a93344f60d511e761 Mon Sep 17 00:00:00 2001 From: Jeremy Gill Date: Wed, 14 Apr 2021 16:39:46 -0400 Subject: [PATCH] Journald: Close unix socket after use. This is done to ensure unix sockets aren't left dangling after each Enabled() call, which can lead to eventual process resource exhaustion. Fixes #366. --- journal/journal_unix.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/journal/journal_unix.go b/journal/journal_unix.go index 7233ecfc..8d58ca0f 100644 --- a/journal/journal_unix.go +++ b/journal/journal_unix.go @@ -65,9 +65,11 @@ func Enabled() bool { return false } - if _, err := net.Dial("unixgram", journalSocket); err != nil { + conn, err := net.Dial("unixgram", journalSocket) + if err != nil { return false } + defer conn.Close() return true }