]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: stop ExampleServer_Shutdown from hanging on error
authorPatrik Lundin <patrik@sigterm.se>
Thu, 4 Jul 2019 22:48:23 +0000 (22:48 +0000)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Fri, 5 Jul 2019 00:26:14 +0000 (00:26 +0000)
Running the example code when not having permissions
to bind to port 80 will cause the program to hang after
printing the error message.

Change-Id: I2433ba2629b362fc8f1731e40cab5eea72ec354f
GitHub-Last-Rev: 0bb3dc08b6f646470fc6ff208ea12bca901a2299
GitHub-Pull-Request: golang/go#32947
Reviewed-on: https://go-review.googlesource.com/c/go/+/185157
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/example_test.go

index 2a09f5f6c6965323a5e642cf5f26f6ea07df792c..a783b4661856287f9e7f606b5d99cc71b86bb9a2 100644 (file)
@@ -132,7 +132,7 @@ func ExampleServer_Shutdown() {
 
        if err := srv.ListenAndServe(); err != http.ErrServerClosed {
                // Error starting or closing listener:
-               log.Printf("HTTP server ListenAndServe: %v", err)
+               log.Fatalf("HTTP server ListenAndServe: %v", err)
        }
 
        <-idleConnsClosed