Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Adds locking around port selection during tribe client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcooklin committed Nov 13, 2015
1 parent 17d4276 commit 90c6f94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mgmt/rest/client/client_tribe_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"net/http"
"strconv"
"sync"
"sync/atomic"
"testing"
"time"

Expand All @@ -40,14 +41,15 @@ import (
"github.com/intelsdi-x/pulse/scheduler"
)

var NextPort = 46000
var NextPort int32 = 46000

func getPort() int {
defer incrPort()
return NextPort
return int(atomic.LoadInt32(&NextPort))
}

func incrPort() {
atomic.AddInt32(&NextPort, 10)
NextPort += 10
}

Expand Down

0 comments on commit 90c6f94

Please sign in to comment.