Skip to content

Commit

Permalink
IV-2077 Bit more idiomatic go
Browse files Browse the repository at this point in the history
  • Loading branch information
psschroeter committed Jun 23, 2015
1 parent e73f537 commit 3bfa01c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ travis-test: lint
# that if there are errors the output of gingko refers to incorrect line numbers
# tip: if you don't like colors use ginkgo -r -noColor
test: lint
ginkgo -r -v
ginkgo -r
ginkgo -r -cover
go tool cover -func=`basename $$PWD`.coverprofile
13 changes: 7 additions & 6 deletions tunnel/wstuncli.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ func (t *WSTunnelClient) Start() error {
// for test purposes we have a signal that tells wstuncli to exit instead of reopening
// a fresh connection. We also block and wait for the initial WS connection to occur
// (or fail). This is also for test purposes, as we run into a race condition
// where the server tries to connect to the client before it can set up the connection.
// where we make requests to the server before the client connection is ready.
t.exitChan = make(chan struct{}, 1)
waitForConn := sync.NewCond(new(sync.Mutex))
waitForConn := make(chan struct{}, 1)

//===== Goroutine =====

Expand All @@ -223,7 +223,10 @@ func (t *WSTunnelClient) Start() error {
var err error
var resp *http.Response
t.ws, resp, err = d.Dial(url, h)
waitForConn.Signal()
select {
case waitForConn <- struct{}{}:
default:
}
if err != nil {
extra := ""
if resp != nil {
Expand Down Expand Up @@ -259,9 +262,7 @@ func (t *WSTunnelClient) Start() error {
}
}()

waitForConn.L.Lock()
waitForConn.Wait()
waitForConn.L.Unlock()
<-waitForConn

return nil
}
Expand Down

0 comments on commit 3bfa01c

Please sign in to comment.