corehttp: ensure node closing/teardown waits for server termination
When closing a node, the node itself only takes care of tearing down its own children. As corehttp sets up a server based on a node, it needs to also ensure that the server is accounted for when determining if the node has been fully closed.
Tor Arne Vestbø committed
Apr 17, 2015 at 18:46 UTC
c9d308491004ae42dc7757c6f5176846410876de
1 file changed
+3
core/corehttp/corehttp.go
+3
@@ -64,6 +64,9 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler
64
var serverError error
65
serverExited := make(chan struct{})
66
67
+ node.Children().Add(1)
68
+ defer node.Children().Done()
69
+
70
go func() {
71
serverError = server.ListenAndServe(host, handler)
72
close(serverExited)