[service] Fix error on unitilized dns monitor
This commit is contained in:
@@ -68,6 +68,10 @@ func (l *ETWSession) IsRunning() bool {
|
||||
|
||||
// FlushTrace flushes the trace buffer.
|
||||
func (l *ETWSession) FlushTrace() error {
|
||||
if l.i == nil {
|
||||
return fmt.Errorf("session not initialized")
|
||||
}
|
||||
|
||||
l.shutdownMutex.Lock()
|
||||
defer l.shutdownMutex.Unlock()
|
||||
|
||||
@@ -86,6 +90,9 @@ func (l *ETWSession) StopTrace() error {
|
||||
|
||||
// DestroySession closes the session and frees the allocated memory. Listener cannot be used after this function is called.
|
||||
func (l *ETWSession) DestroySession() error {
|
||||
if l.i == nil {
|
||||
return fmt.Errorf("session not initialized")
|
||||
}
|
||||
l.shutdownMutex.Lock()
|
||||
defer l.shutdownMutex.Unlock()
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ func initializeSessions(module *DNSMonitor, listener *Listener) error {
|
||||
}
|
||||
|
||||
func (l *Listener) flush() error {
|
||||
if l.etw == nil {
|
||||
return fmt.Errorf("etw not initialized")
|
||||
}
|
||||
return l.etw.FlushTrace()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user