1. 17 Dec, 2015 13 commits
  2. 16 Dec, 2015 23 commits
  3. 15 Dec, 2015 4 commits
    • Robert Griesemer's avatar
      spec: be clearer about which parameter section can be variadic · 57c81ef2
      Robert Griesemer authored
      Fixes #13595.
      
      Change-Id: I870ddc97ea25b7f6f7a1bb1a78e5e4874fba1ddc
      Reviewed-on: https://go-review.googlesource.com/17871Reviewed-by: 's avatarRob Pike <r@golang.org>
      57c81ef2
    • Brad Fitzpatrick's avatar
      net: add Dialer.Cancel to cancel pending dials · 24a83d35
      Brad Fitzpatrick authored
      Dialer.Cancel is a new optional <-chan struct{} channel whose closure
      indicates that the dial should be canceled. It is compatible with the
      x/net/context and http.Request.Cancel types.
      
      Tested by hand with:
      
      package main
      
          import (
                  "log"
                  "net"
                  "time"
          )
      
          func main() {
                  log.Printf("start.")
                  var d net.Dialer
                  cancel := make(chan struct{})
                  time.AfterFunc(2*time.Second, func() {
                          log.Printf("timeout firing")
                          close(cancel)
                  })
                  d.Cancel = cancel
                  c, err := d.Dial("tcp", "192.168.0.1:22")
                  if err != nil {
                          log.Print(err)
                          return
                  }
                  log.Fatalf("unexpected connect: %v", c)
          }
      
      Which says:
      
          2015/12/14 22:24:58 start.
          2015/12/14 22:25:00 timeout firing
          2015/12/14 22:25:00 dial tcp 192.168.0.1:22: operation was canceled
      
      Fixes #11225
      
      Change-Id: I2ef39e3a540e29fe6bfec03ab7a629a6b187fcb3
      Reviewed-on: https://go-review.googlesource.com/17821Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      24a83d35
    • Brad Fitzpatrick's avatar
      net/http: maybe deflake TestCancelRequestMidBody_h2 on linux-noopt builder · 479c47e4
      Brad Fitzpatrick authored
      This might deflake it. Or it'll at least give us more debugging clues.
      
      Fixes #13626 maybe
      
      Change-Id: Ie8cd0375d60dad033ec6a64830a90e7b9152a3d9
      Reviewed-on: https://go-review.googlesource.com/17825Reviewed-by: 's avatarAustin Clements <austin@google.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      479c47e4
    • Brad Fitzpatrick's avatar
      net/http: rework CloseNotifier implementation, clarify expectations in docs · 99fb1919
      Brad Fitzpatrick authored
      CloseNotifier wasn't well specified previously. This CL simplifies its
      implementation, clarifies the public documentation on CloseNotifier,
      clarifies internal documentation on conn, and fixes two CloseNotifier
      bugs in the process.
      
      The main change, though, is tightening the rules and expectations for using
      CloseNotifier:
      
      * the caller must consume the Request.Body first (old rule, unwritten)
      * the received value is the "true" value (old rule, unwritten)
      * no promises for channel sends after Handler returns (old rule, unwritten)
      * a subsequent pipelined request fires the CloseNotifier (new behavior;
        previously it never fired and thus effectively deadlocked as in #13165)
      * advise that it should only be used without HTTP/1.1 pipelining (use HTTP/2
        or non-idempotent browsers). Not that browsers actually use pipelining.
      
      The main implementation change is that each Handler now gets its own
      CloseNotifier channel value, rather than sharing one between the whole
      conn. This means Handlers can't affect subsequent requests. This is
      how HTTP/2's Server works too. The old docs never clarified a behavior
      either way. The other side effect of each request getting its own
      CloseNotifier channel is that one handler can't "poison" the
      underlying conn preventing subsequent requests on the same connection
      from using CloseNotifier (this is #9763).
      
      In the old implementation, once any request on a connection used
      ClosedNotifier, the conn's underlying bufio.Reader source was switched
      from the TCPConn to the read side of the pipe being fed by a
      never-ending copy. Since it was impossible to abort that never-ending
      copy, we could never get back to a fresh state where it was possible
      to return the underlying TCPConn to callers of Hijack. Now, instead of
      a never-ending Copy, the background goroutine doing a Read from the
      TCPConn (or *tls.Conn) only reads a single byte. That single byte
      can be in the request body, a socket timeout error, io.EOF error, or
      the first byte of the second body. In any case, the new *connReader
      type stitches sync and async reads together like an io.MultiReader. To
      clarify the flow of Read data and combat the complexity of too many
      wrapper Reader types, the *connReader absorbs the io.LimitReader
      previously used for bounding request header reads.  The
      liveSwitchReader type is removed. (an unused switchWriter type is also
      removed)
      
      Many fields on *conn are also documented more fully.
      
      Fixes #9763 (CloseNotify + Hijack together)
      Fixes #13165 (deadlock with CloseNotify + pipelined requests)
      
      Change-Id: I40abc0a1992d05b294d627d1838c33cbccb9dd65
      Reviewed-on: https://go-review.googlesource.com/17750Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      99fb1919