Skip to content

Commit

Permalink
Merge pull request ipfs/kubo#1385 from rht/cleanup-ctxgroup-goprocess
Browse files Browse the repository at this point in the history
 Cleanup ctxgroup goprocess

This commit was moved from ipfs/kubo@4c55b30
  • Loading branch information
jbenet committed Jul 5, 2015
2 parents 914a03c + 367d058 commit e34779c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gateway/core/corehttp/corehttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
core "github.com/ipfs/go-ipfs/core"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
)
Expand Down Expand Up @@ -78,20 +79,17 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error
var serverError error
serverExited := make(chan struct{})

node.Children().Add(1)
defer node.Children().Done()

go func() {
node.Process().Go(func(p goprocess.Process) {
serverError = http.Serve(lis, handler)
close(serverExited)
}()
})

// wait for server to exit.
select {
case <-serverExited:

// if node being closed before server exits, close server
case <-node.Closing():
case <-node.Process().Closing():
log.Infof("server at %s terminating...", addr)

lis.Close()
Expand Down

0 comments on commit e34779c

Please sign in to comment.