test: signal the process for exit before shutting down local goroutines

This commit is tied to the prior commit and it patches up a lingering
race condition and deadlock that can arise due to now properly waiting
for all goroutine  to exit before concluding the shutdown process.
This commit is contained in:
Olaoluwa Osuntokun 2017-04-17 16:09:47 -07:00
parent bfdb2bebe2
commit e947162d97
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 10 additions and 4 deletions

View File

@ -1509,6 +1509,7 @@ func testRevokedCloseRetribution(net *networkHarness, t *harnessTest) {
// Next query for Bob's channel state, as we sent 3 payments of 10k
// satoshis each, Bob should now see his balance as being 30k satoshis.
time.Sleep(time.Millisecond * 200)
bobChan, err := getBobChanInfo()
if err != nil {
t.Fatalf("unable to get bob's channel info: %v", err)

View File

@ -279,12 +279,17 @@ func (l *lightningNode) Stop() error {
default:
}
if runtime.GOOS == "windows" {
if err := l.cmd.Process.Signal(os.Kill); err != nil {
return err
}
} else if err := l.cmd.Process.Signal(os.Interrupt); err != nil {
return err
}
close(l.quit)
l.wg.Wait()
if runtime.GOOS == "windows" {
return l.cmd.Process.Signal(os.Kill)
}
return l.cmd.Process.Signal(os.Interrupt)
return nil
}
// Restart attempts to restart a lightning node by shutting it down cleanly,