FAQ
Reviewers: golang-dev1,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
os/exec: fix leaked http transport in TestExtraFiles

Fixes issue 5593.

The http.Get call was leaking a file descriptor. This fd would normally
be cleaned up by the finaliser on os.File, but occasionally this was not
done in time. It is my guess that this is what was setting off the
TestPipeLookPathLeak failure

Please review this at https://codereview.appspot.com/10402045/

Affected files:
    M src/pkg/os/exec/exec_test.go


Index: src/pkg/os/exec/exec_test.go
===================================================================
--- a/src/pkg/os/exec/exec_test.go
+++ b/src/pkg/os/exec/exec_test.go
@@ -7,12 +7,14 @@
   import (
    "bufio"
    "bytes"
+ "crypto/tls"
    "fmt"
    "io"
    "io/ioutil"
    "net"
    "net/http"
    "net/http/httptest"
+ "net/url"
    "os"
    "path/filepath"
    "runtime"
@@ -345,7 +347,22 @@
     w.Write([]byte("Hello"))
    }))
    defer ts.Close()
- http.Get(ts.URL) // ignore result; just calling to force root cert loading
+
+ // construct a http connection manually bypassing any caching in
http.Client
+ u, _ := url.Parse(ts.URL)
+ conn, err := tls.Dial("tcp", u.Host, &tls.Config{InsecureSkipVerify:
true, ServerName: "127.0.0.1"})
+ if err != nil {
+ t.Fatalf("dial failed: %v", err)
+ }
+ const r = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"
+ if _, err := conn.Write([]byte(r)); err != nil {
+ t.Fatalf("write failed: %v", err)
+ }
+ // ignore result; just calling to force root cert loading
+ if _, err := ioutil.ReadAll(conn); err != nil {
+ t.Fatalf("ReadAll failed: %v", err)
+ }
+ conn.Close()

    tf, err := ioutil.TempFile("", "")
    if err != nil {


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Minux at Jun 19, 2013 at 7:38 pm
    if we just want to force loading the root certificates, we just need this
    one liner:
    (&x509.Certificate{}).Verify(x509.VerifyOptions{})

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJun 19, '13 at 3:39a
activeJun 19, '13 at 7:38p
posts2
users2
websitegolang.org

2 users in discussion

Dave: 1 post Minux: 1 post

People

Translate

site design / logo © 2022 Grokbase