Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
discoverd/client: lock it up
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium committed Jan 6, 2014
1 parent 91480cc commit a090611
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ func (c *Client) UnregisterAll() error {
}

var defaultClient *Client
var defaultEnsureLock = &sync.Mutex{}

func Connect(addr string) (err error) {
if addr == "" {
Expand All @@ -441,6 +442,8 @@ func Connect(addr string) (err error) {
}

func ensureDefaultConnected() error {
defaultEnsureLock.Lock()
defer defaultEnsureLock.Unlock()
if defaultClient == nil {
return Connect("")
}
Expand Down

0 comments on commit a090611

Please sign in to comment.