agent: shutdown delegate if created

When the TestAgent shuts down a half-started agent
the delegate may not have been created at this point.
This commit is contained in:
Frank Schroeder 2017-05-22 23:59:54 +02:00
parent 6a40fe026e
commit 449eceec11
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
1 changed files with 5 additions and 2 deletions

View File

@ -1011,8 +1011,11 @@ func (a *Agent) Shutdown() error {
chk.Stop()
}
err := a.delegate.Shutdown()
var err error
if a.delegate != nil {
err = a.delegate.Shutdown()
a.logger.Print("[DEBUG] agent: delegate down")
}
pidErr := a.deletePid()
if pidErr != nil {