Skip to content

Commit

Permalink
Merge pull request #12 from ascotan/master
Browse files Browse the repository at this point in the history
  • Loading branch information
k-sone authored Dec 7, 2016
2 parents 1cdaa85 + c3db875 commit 4efb4b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ func initRandom() {
random = rand.New(rand.NewSource(time.Now().UnixNano()))
}

var reqMutex sync.Mutex
func genRequestId() int {
randOnce.Do(initRandom)
return int(random.Int31())
reqMutex.Lock()
val := int(random.Int31())
reqMutex.Unlock()
return val
}

func genSalt32() int32 {
Expand Down

0 comments on commit 4efb4b6

Please sign in to comment.