Skip to content

Commit

Permalink
Fix race condition when accesing Graphite listener
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolep committed Apr 24, 2015
1 parent 79d3925 commit b2be0c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [#2418](https://github.com/influxdb/influxdb/pull/2418): Fix raft node getting stuck in candidate state
- [#2415](https://github.com/influxdb/influxdb/pull/2415): Raft leader ID now set on election after failover.
- [#2426](https://github.com/influxdb/influxdb/pull/2426): Fix race condition around listener address in openTSDB server.
- [#2426](https://github.com/influxdb/influxdb/pull/2426): Fix race condition around listener address in Graphite server.

### Features
- [#2410](https://github.com/influxdb/influxdb/pull/2410) Allow configuration of Raft timers
Expand Down
5 changes: 5 additions & 0 deletions graphite/graphite_tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type TCPServer struct {
Logger *log.Logger

host string
mu sync.Mutex
}

// NewTCPServer returns a new instance of a TCPServer.
Expand All @@ -47,7 +48,9 @@ func (t *TCPServer) ListenAndServe(iface string) error {
return err
}
t.listener = &ln
t.mu.Lock()
t.host = ln.Addr().String()
t.mu.Unlock()

t.Logger.Println("listening on TCP connection", ln.Addr().String())
t.wg.Add(1)
Expand All @@ -72,6 +75,8 @@ func (t *TCPServer) ListenAndServe(iface string) error {
}

func (t *TCPServer) Host() string {
t.mu.Lock()
defer t.mu.Unlock()
return t.host
}

Expand Down

0 comments on commit b2be0c3

Please sign in to comment.