Skip to content

Commit

Permalink
[FAB-12437] fix data race in peer/node/start test
Browse files Browse the repository at this point in the history
Change-Id: Ieabe30f932ee981514b3f3046990c99041c2a88d
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm authored and mastersingh24 committed Oct 14, 2018
1 parent a79ac3c commit 9d3f4f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions peer/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func serve(args []string) error {

logger.Infof("Starting peer with ID=[%s], network ID=[%s], address=[%s]", peerEndpoint.Id, networkID, peerEndpoint.Address)

// Get configuration before starting go routines to avoid
// racing in tests
profileEnabled := viper.GetBool("peer.profile.enabled")
profileListenAddress := viper.GetString("peer.profile.listenAddress")

// Start the grpc server. Done in a goroutine so we can deploy the
// genesis block if needed.
serve := make(chan error)
Expand All @@ -356,9 +361,8 @@ func serve(args []string) error {
}()

// Start profiling http endpoint if enabled
if viper.GetBool("peer.profile.enabled") {
if profileEnabled {
go func() {
profileListenAddress := viper.GetString("peer.profile.listenAddress")
logger.Infof("Starting profiling server with listenAddress = %s", profileListenAddress)
if profileErr := http.ListenAndServe(profileListenAddress, nil); profileErr != nil {
logger.Errorf("Error starting profiler: %s", profileErr)
Expand Down

0 comments on commit 9d3f4f2

Please sign in to comment.