p2p: return increased timeout
This commit is contained in:
parent
d49da4348c
commit
f0d9f61bf6
@ -445,7 +445,18 @@ func (srv *Server) Stop() {
|
|||||||
}
|
}
|
||||||
close(srv.quit)
|
close(srv.quit)
|
||||||
srv.lock.Unlock()
|
srv.lock.Unlock()
|
||||||
|
|
||||||
|
stopChan := make(chan struct{})
|
||||||
|
go func() {
|
||||||
srv.loopWG.Wait()
|
srv.loopWG.Wait()
|
||||||
|
close(stopChan)
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-stopChan:
|
||||||
|
case <-time.After(defaultDialTimeout): // we should use defaultDialTimeout as we can dial just before the shutdown
|
||||||
|
srv.log.Warn("stop p2p server timeout, forcing stop")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sharedUDPConn implements a shared connection. Write sends messages to the underlying connection while read returns
|
// sharedUDPConn implements a shared connection. Write sends messages to the underlying connection while read returns
|
||||||
|
@ -223,8 +223,8 @@ func TestServerStopTimeout(t *testing.T) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-stopChan:
|
case <-stopChan:
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(defaultDialTimeout + 1*time.Second):
|
||||||
t.Error("server should be shutdown in 10 seconds")
|
t.Error("server should be shutdown in defaultDialTimeout + 1 seconds")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user