mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 01:12:24 +08:00
make odds of 'process added after close' panic less likely
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -79,6 +79,12 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error
|
||||
var serverError error
|
||||
serverExited := make(chan struct{})
|
||||
|
||||
select {
|
||||
case <-node.Process().Closing():
|
||||
return fmt.Errorf("failed to start server, process closing")
|
||||
default:
|
||||
}
|
||||
|
||||
node.Process().Go(func(p goprocess.Process) {
|
||||
serverError = http.Serve(lis, handler)
|
||||
close(serverExited)
|
||||
|
Reference in New Issue
Block a user