Fix review comments

This commit is contained in:
Andrey Meshkov
2019-02-11 14:22:36 +03:00
parent b477b67428
commit a40ddb094b
6 changed files with 21 additions and 15 deletions

View File

@@ -116,6 +116,14 @@ func (s *Server) startInternal(config *ServerConfig) error {
return errors.New("DNS server is already started")
}
if s.queryLog == nil {
s.queryLog = newQueryLog(".")
}
if s.stats == nil {
s.stats = newStats()
}
err := s.initDNSFilter()
if err != nil {
return err
@@ -200,7 +208,7 @@ func (s *Server) stopInternal() error {
}
// flush remainder to file
return s.queryLog.clearLogBuffer()
return s.queryLog.flushLogBuffer()
}
// IsRunning returns true if the DNS server is running
@@ -242,8 +250,8 @@ func (s *Server) GetStatsTop() *StatsTop {
return s.queryLog.runningTop.getStatsTop()
}
// ResetStats purges current server stats
func (s *Server) ResetStats() {
// PurgeStats purges current server stats
func (s *Server) PurgeStats() {
// TODO: Locks?
s.stats.purgeStats()
}

View File

@@ -19,8 +19,8 @@ var (
const enableGzip = false
// clearLogBuffer flushes the current buffer to file and resets the current buffer
func (l *queryLog) clearLogBuffer() error {
// flushLogBuffer flushes the current buffer to file and resets the current buffer
func (l *queryLog) flushLogBuffer() error {
// flush remainder to file
l.logBufferLock.Lock()
flushBuffer := l.logBuffer