1. 17 Dec, 2015 12 commits
  2. 16 Dec, 2015 23 commits
  3. 15 Dec, 2015 5 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
    • Austin Clements's avatar
      runtime: only trigger forced GC if GC is not running · 01baf13b
      Austin Clements authored
      Currently, sysmon triggers a forced GC solely based on
      memstats.last_gc. However, memstats.last_gc isn't updated until mark
      termination, so once sysmon starts triggering forced GC, it will keep
      triggering them until GC finishes. The first of these actually starts
      a GC; the remainder up to the last print "GC forced", but gcStart
      returns immediately because gcphase != _GCoff; then the last may start
      another GC if the previous GC finishes (and sets last_gc) between
      sysmon triggering it and gcStart checking the GC phase.
      
      Fix this by expanding the condition for starting a forced GC to also
      require that no GC is currently running. This, combined with the way
      forcegchelper blocks until the GC cycle is started, ensures sysmon
      only starts one GC when the time exceeds the forced GC threshold.
      
      Fixes #13458.
      
      Change-Id: Ie6cf841927f6085136be3f45259956cd5cf10d23
      Reviewed-on: https://go-review.googlesource.com/17819
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      01baf13b