Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journald unix sockets are leaked whenever Enabled() is called #366

Closed
jeremy-gill opened this issue Apr 14, 2021 · 0 comments · Fixed by #367
Closed

journald unix sockets are leaked whenever Enabled() is called #366

jeremy-gill opened this issue Apr 14, 2021 · 0 comments · Fixed by #367

Comments

@jeremy-gill
Copy link
Contributor

The journald logging code appears to leak a unix datagram socket once per call to journal.Enabled() on linux platforms.

An example bit of code follows that leads to an eventual error once the number of open file handles hits the operating system per-process maximum.

package main

import (
	"fmt"

	"github.com/rs/zerolog"
	"github.com/rs/zerolog/journald"
	"github.com/rs/zerolog/log"
)

func main() {

	var (
		i int
	)

	writers := journald.NewJournalDWriter()
	log.Logger = log.Output(writers)

	for {
		log.WithLevel(zerolog.InfoLevel).Msg(fmt.Sprintf("Hello world %d", i))
		i++
	}
}
jeremy-gill pushed a commit to jeremy-gill/go-systemd that referenced this issue Apr 14, 2021
This is done to ensure unix sockets aren't left dangling after each Enabled() call, which
can lead to eventual process resource exhaustion. Fixes coreos#366.
jeremy-gill pushed a commit to jeremy-gill/go-systemd that referenced this issue Apr 15, 2021
This is done to ensure unix sockets aren't left dangling after each Enabled() call, which
can lead to eventual process resource exhaustion. Fixes coreos#366.
jeremy-gill pushed a commit to jeremy-gill/go-systemd that referenced this issue Apr 15, 2021
This is done to ensure unix sockets aren't left dangling after each Enabled() call, which
can lead to eventual process resource exhaustion. Fixes coreos#366.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant