mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
log/sockstatlog: don't block for more than 5s on shutdown
Fixes tailscale/corp#21618 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
parent
9609b26541
commit
5d61d1c7b0
@ -730,7 +730,9 @@ func (b *LocalBackend) Shutdown() {
|
|||||||
b.webClientShutdown()
|
b.webClientShutdown()
|
||||||
|
|
||||||
if b.sockstatLogger != nil {
|
if b.sockstatLogger != nil {
|
||||||
b.sockstatLogger.Shutdown()
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
b.sockstatLogger.Shutdown(ctx)
|
||||||
}
|
}
|
||||||
if b.peerAPIServer != nil {
|
if b.peerAPIServer != nil {
|
||||||
b.peerAPIServer.taildrop.Shutdown()
|
b.peerAPIServer.taildrop.Shutdown()
|
||||||
|
@ -242,12 +242,12 @@ func (l *Logger) Flush() {
|
|||||||
l.logger.StartFlush()
|
l.logger.StartFlush()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Shutdown() {
|
func (l *Logger) Shutdown(ctx context.Context) {
|
||||||
if l.cancelFn != nil {
|
if l.cancelFn != nil {
|
||||||
l.cancelFn()
|
l.cancelFn()
|
||||||
}
|
}
|
||||||
l.filch.Close()
|
l.filch.Close()
|
||||||
l.logger.Shutdown(context.Background())
|
l.logger.Shutdown(ctx)
|
||||||
|
|
||||||
type closeIdler interface {
|
type closeIdler interface {
|
||||||
CloseIdleConnections()
|
CloseIdleConnections()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package sockstatlog
|
package sockstatlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
@ -28,7 +29,7 @@ func TestResourceCleanup(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
lg.Write([]byte("hello"))
|
lg.Write([]byte("hello"))
|
||||||
lg.Shutdown()
|
lg.Shutdown(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDelta(t *testing.T) {
|
func TestDelta(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user