mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
log/sockstatlog: make shutdown close idle connections
Updates tailscale/corp#10030 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
9e81db50f6
commit
4a89642f7f
@ -36,6 +36,8 @@ type Logger struct {
|
||||
logf logger.Logf
|
||||
|
||||
logger *logtail.Logger
|
||||
filch *filch.Filch
|
||||
tr *http.Transport
|
||||
}
|
||||
|
||||
// deltaStat represents the bytes transferred during a time period.
|
||||
@ -88,6 +90,8 @@ func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID) (*Logger,
|
||||
cancelFn: cancel,
|
||||
ticker: time.NewTicker(pollPeriod),
|
||||
logf: logf,
|
||||
filch: filch,
|
||||
tr: logpolicy.NewLogtailTransport(logtail.DefaultHost),
|
||||
}
|
||||
logger.logger = logtail.NewLogger(logtail.Config{
|
||||
BaseURL: logpolicy.LogURL(),
|
||||
@ -107,7 +111,7 @@ func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID) (*Logger,
|
||||
},
|
||||
Stderr: io.Discard, // don't log to stderr
|
||||
|
||||
HTTPC: &http.Client{Transport: logpolicy.NewLogtailTransport(logtail.DefaultHost)},
|
||||
HTTPC: &http.Client{Transport: logger.tr},
|
||||
}, logf)
|
||||
|
||||
go logger.poll()
|
||||
@ -166,8 +170,10 @@ func (l *Logger) Flush() {
|
||||
|
||||
func (l *Logger) Shutdown() {
|
||||
l.ticker.Stop()
|
||||
l.logger.Shutdown(context.Background())
|
||||
l.logger.Shutdown(l.ctx)
|
||||
l.cancelFn()
|
||||
l.filch.Close()
|
||||
l.tr.CloseIdleConnections()
|
||||
}
|
||||
|
||||
// delta calculates the delta stats between two SockStats snapshots.
|
||||
|
Loading…
Reference in New Issue
Block a user