Skip to content

Commit

Permalink
Merge pull request #2370 from influxdb/tsdb-data-race
Browse files Browse the repository at this point in the history
Fix data race for openTSDB listener addr
  • Loading branch information
corylanou committed Apr 21, 2015
2 parents 4cc1068 + 5ec0390 commit ec99077
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.9.0-rc27 [unreleased]

### Bugfixes
- [#2370](https://github.com/influxdb/influxdb/pull/2370): Fix data race in openTSDB endpoint.

## v0.9.0-rc26 [04-21-2015]

### Features
Expand Down
6 changes: 3 additions & 3 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ func Test_ServerOpenTSDBIntegration(t *testing.T) {
createDatabase(t, testName, nodes, "opentsdb")
createRetentionPolicy(t, testName, nodes, "opentsdb", "raw", len(nodes))

// Connect to the graphite endpoint we just spun up
// Connect to the openTSDB endpoint we just spun up
host := nodes[0].node.OpenTSDBServer.Addr().String()
conn, err := net.Dial("tcp", host)
if err != nil {
Expand Down Expand Up @@ -1933,7 +1933,7 @@ func Test_ServerOpenTSDBIntegration_WithTags(t *testing.T) {
createDatabase(t, testName, nodes, "opentsdb")
createRetentionPolicy(t, testName, nodes, "opentsdb", "raw", len(nodes))

// Connect to the graphite endpoint we just spun up
// Connect to the openTSDB endpoint we just spun up
host := nodes[0].node.OpenTSDBServer.Addr().String()
conn, err := net.Dial("tcp", host)
if err != nil {
Expand Down Expand Up @@ -1992,7 +1992,7 @@ func Test_ServerOpenTSDBIntegration_BadData(t *testing.T) {
createDatabase(t, testName, nodes, "opentsdb")
createRetentionPolicy(t, testName, nodes, "opentsdb", "raw", len(nodes))

// Connect to the graphite endpoint we just spun up
// Connect to the openTSDB endpoint we just spun up
host := nodes[0].node.OpenTSDBServer.Addr().String()
conn, err := net.Dial("tcp", host)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion opentsdb/opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Server struct {

listener *net.TCPListener
wg sync.WaitGroup

addr net.Addr
}

func NewServer(w SeriesWriter, retpol string, db string) *Server {
Expand All @@ -50,7 +52,7 @@ func NewServer(w SeriesWriter, retpol string, db string) *Server {
}

func (s *Server) Addr() net.Addr {
return s.listener.Addr()
return s.addr
}

func (s *Server) ListenAndServe(listenAddress string) {
Expand All @@ -68,6 +70,8 @@ func (s *Server) ListenAndServe(listenAddress string) {
return
}

s.addr = s.listener.Addr()

s.wg.Add(1)
go func() {
defer s.wg.Done()
Expand Down

0 comments on commit ec99077

Please sign in to comment.