Split part of DNSServer.Start() to a separate ActivateAndServe()

Specifically, move the part that blocks, and call that as necessary.
This means Start() can run on the caller's goroutine and avoid race conditions.
This commit is contained in:
Bryan Boreham committed 2015-06-17 11:35:53 +01:00
1 parent 1b57a24789
commit 9636675c2c
4 files changed
+19 -6

No files matched your search

+9 -3
View File
@@ -69,7 +69,9 @@ func TestServerDbCacheInvalidation(t *testing.T) {
MaxAnswers: 4,
})
wt.AssertNoErr(t, err)
go srv.Start()
err = srv.Start()
wt.AssertNoErr(t, err)
go srv.ActivateAndServe()
defer srv.Stop()
time.Sleep(100 * time.Millisecond) // Allow server goroutine to start
@@ -202,7 +204,9 @@ func TestServerCacheExpiration(t *testing.T) {
CacheNegLocalTTL: negativeLocalTTL,
})
wt.AssertNoErr(t, err)
go srv.Start()
err = srv.Start()
wt.AssertNoErr(t, err)
go srv.ActivateAndServe()
defer srv.Stop()
time.Sleep(100 * time.Millisecond) // Allow server goroutine to start
@@ -287,7 +291,9 @@ func TestServerCacheRefresh(t *testing.T) {
MaxAnswers: 4,
})
wt.AssertNoErr(t, err)
go srv.Start()
err = srv.Start()
wt.AssertNoErr(t, err)
go srv.ActivateAndServe()
defer srv.Stop()
time.Sleep(100 * time.Millisecond) // Allow sever goroutine to start