Skip to content

Commit

Permalink
Fix chain build goroutine leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Andersen committed Jul 29, 2016
1 parent eabe676 commit 1fa994b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
3 changes: 3 additions & 0 deletions api/async_full.go
Expand Up @@ -375,14 +375,17 @@ func (c *BosswaveClient) BuildChain(p *BuildChainParams) (chan *objects.DChain,
}
parts := strings.SplitN(p.URI, "/", 2)
if len(parts) != 2 {
close(status)
return nil, bwe.M(bwe.BadURI, "Bad URI")
}
rnsvk, err := c.BW().ResolveKey(parts[0])
if err != nil {
close(status)
return nil, err
}
cb := NewChainBuilder(c, crypto.FmtKey(rnsvk)+"/"+parts[1], p.Permissions, p.To, status)
if cb == nil {
close(status)
return nil, bwe.M(bwe.BadChainBuildParams, "Could not construct CB: bad params")
}
rv := make(chan *objects.DChain)
Expand Down
2 changes: 1 addition & 1 deletion api/chainbuilder.go
Expand Up @@ -153,6 +153,7 @@ func (b *ChainBuilder) Build() ([]*objects.DChain, error) {
uri: b.uri,
perms: b.perms,
}
defer close(b.status)
copy(ck.target[:], b.target)
copy(ck.nsvk[:], b.nsvk)
cached, states := b.cl.bw.resolveBuiltChain(ck)
Expand Down Expand Up @@ -229,7 +230,6 @@ func (b *ChainBuilder) Build() ([]*objects.DChain, error) {
e = e.Next()
}
b.status <- "chain build operation complete"
close(b.status)
b.cl.bw.cacheBuiltChains(ck, rv)
return rv, nil
}
10 changes: 6 additions & 4 deletions bw.go
Expand Up @@ -31,6 +31,8 @@ import (

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
startProfile()
defer stopProfile()
app := cli.NewApp()
app.Name = "bw2"
app.Usage = "BossWave 2 universal tool. Run public or private routers, manage DoTs and DChains, and more"
Expand Down Expand Up @@ -321,12 +323,12 @@ func main() {
Action: cli.ActionFunc(actionInspect),
Flags: []cli.Flag{
cli.BoolFlag{
Name: "publish, p",
Usage: "publish inspected objects to the registry",
Name: "publish, p",
Usage: "publish inspected objects to the registry",
},
cli.BoolFlag{
Name: "qrcode, q",
Usage: "makes QR Codes for entities with available siging keys",
Name: "qrcode, q",
Usage: "makes QR Codes for entities with available siging keys",
},
bflag,
},
Expand Down
10 changes: 10 additions & 0 deletions bw2_noprofile.go
@@ -0,0 +1,10 @@
// +build !profiling

package main

func startProfile() {
}

func stopProfile() {

}
16 changes: 16 additions & 0 deletions bw2_profile.go
@@ -0,0 +1,16 @@
// +build profiling

package main

import (
"net/http"
_ "net/http/pprof"
)

func startProfile() {
go http.ListenAndServe(":8080", http.DefaultServeMux)
}

func stopProfile() {

}
4 changes: 2 additions & 2 deletions util/version.go
@@ -1,8 +1,8 @@
package util

//The version of BW2 this is
const BW2Version = "2.4.10 'Hadron'"
const BW2Version = "2.4.11 'Hadron'"
const BW2VersionMajor = 2
const BW2VersionMinor = 4
const BW2VersionSubminor = 10
const BW2VersionSubminor = 11
const BW2VersionName = "Hadron"

0 comments on commit 1fa994b

Please sign in to comment.