Skip to content

Commit

Permalink
fix: git daemon listens only when starting it
Browse files Browse the repository at this point in the history
This was inconsistent with the other servers.
  • Loading branch information
Jonatan Wallmander committed Nov 21, 2024
1 parent 682dccb commit f55801d
Showing 1 changed file with 15 additions and 5 deletions.
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 @@ func NewGitDaemon(ctx context.Context) (*GitDaemon, error) {
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 @@ func (d *GitDaemon) Close() error {

// 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

0 comments on commit f55801d

Please sign in to comment.