dnsforward -- flush querylog to file on server stop

This commit is contained in:
Eugene Bujak 2018-12-05 14:21:48 +03:00
parent e357620740
commit 9b43e07d7f
1 changed files with 12 additions and 0 deletions

View File

@ -215,6 +215,18 @@ func (s *Server) Stop() error {
return errorx.Decorate(err, "Couldn't close UDP listening socket") return errorx.Decorate(err, "Couldn't close UDP listening socket")
} }
} }
// flush remainder to file
logBufferLock.Lock()
flushBuffer := logBuffer
logBuffer = nil
logBufferLock.Unlock()
err := flushToFile(flushBuffer)
if err != nil {
log.Printf("Saving querylog to file failed: %s", err)
return err
}
return nil return nil
} }