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

fix: git daemon listens only when starting it #607

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@
conns: connections{m: make(map[net.Conn]struct{})},
logger: log.FromContext(ctx).WithPrefix("gitdaemon"),
}
listener, err := net.Listen("tcp", d.addr)
if err != nil {
return nil, err
}
d.listener = listener
return d, nil
}

// Start starts the Git TCP daemon.
func (d *GitDaemon) Start() error {
// listen on the socket
{
listener, err := net.Listen("tcp", d.addr)
if err != nil {
return err

Check failure on line 79 in pkg/daemon/daemon.go

View workflow job for this annotation

GitHub Actions / lint-soft

error returned from external package is unwrapped: sig: func net.Listen(network string, address string) (net.Listener, error) (wrapcheck)
}
d.listener = listener
}

// close eventual connections to the socket
defer d.listener.Close() // nolint: errcheck

d.wg.Add(1)
Expand Down Expand Up @@ -308,6 +313,11 @@

// Shutdown gracefully shuts down the daemon.
func (d *GitDaemon) Shutdown(ctx context.Context) error {
// in the case when git daemon was never started
if d.listener == nil {
return nil
}

d.once.Do(func() { close(d.finished) })
err := d.listener.Close()
finished := make(chan struct{}, 1)
Expand Down
Loading