Fix deadlock in nettest webserver

This commit is contained in:
Jeff Grafton
2016-02-11 15:32:46 -08:00
parent 1c6a223eaa
commit 214d018911
2 changed files with 4 additions and 3 deletions

View File

@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
TAG = 1.6
TAG = 1.7
PREFIX = gcr.io/google_containers
all: push
webserver: webserver.go
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./webserver.go
CGO_ENABLED=0 GOOS=linux godep go build -a -installsuffix cgo -ldflags '-w' ./webserver.go
container: image

View File

@@ -90,7 +90,8 @@ func (s *State) serveStatus(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "running")
return
}
s.Logf("Declaring failure for %s/%s with %d sent and %d received and %d peers", *namespace, *service, len(s.Sent), len(s.Received), *peerCount)
// Logf can't be called while holding the lock, so defer using a goroutine
go s.Logf("Declaring failure for %s/%s with %d sent and %d received and %d peers", *namespace, *service, len(s.Sent), len(s.Received), *peerCount)
fmt.Fprintf(w, "fail")
}