Commit c50a8416 authored by Paul Marks's avatar Paul Marks Committed by Mikio Hara

net: dialChannel should not treat an expired deadline as noDeadline.

Now, only a zero deadline is interpreted as noDeadline.  Any other time
in the past yields an immediate timeout.

TestConnectDeadlineInThePast already covers this case.  We just need to
un-skip it for plan9, where dialChannel is used.

Change-Id: I995fd1a632c31f8004dac772c3d7c43a2a5853b0
Reviewed-on: https://go-review.googlesource.com/8435Reviewed-by: 's avatarMikio Hara <mikioh.mikioh@gmail.com>
parent 5242d2ce
...@@ -12,12 +12,12 @@ import "time" ...@@ -12,12 +12,12 @@ import "time"
// used on operating systems where the deadline hasn't been pushed // used on operating systems where the deadline hasn't been pushed
// down into the pollserver. (Plan 9 and some old versions of Windows) // down into the pollserver. (Plan 9 and some old versions of Windows)
func dialChannel(net string, ra Addr, dialer func(time.Time) (Conn, error), deadline time.Time) (Conn, error) { func dialChannel(net string, ra Addr, dialer func(time.Time) (Conn, error), deadline time.Time) (Conn, error) {
var timeout time.Duration if deadline.IsZero() {
if !deadline.IsZero() { return dialer(noDeadline)
timeout = deadline.Sub(time.Now())
} }
timeout := deadline.Sub(time.Now())
if timeout <= 0 { if timeout <= 0 {
return dialer(noDeadline) return nil, &OpError{Op: "dial", Net: net, Addr: ra, Err: errTimeout}
} }
t := time.NewTimer(timeout) t := time.NewTimer(timeout)
defer t.Stop() defer t.Stop()
......
...@@ -682,11 +682,6 @@ func TestAcceptDeadlineConnectionAvailable(t *testing.T) { ...@@ -682,11 +682,6 @@ func TestAcceptDeadlineConnectionAvailable(t *testing.T) {
// TestConnectDeadlineInThePast tests that connect deadlines work, even // TestConnectDeadlineInThePast tests that connect deadlines work, even
// if the connection can be established w/o blocking. // if the connection can be established w/o blocking.
func TestConnectDeadlineInThePast(t *testing.T) { func TestConnectDeadlineInThePast(t *testing.T) {
switch runtime.GOOS {
case "plan9":
t.Skipf("skipping test on %q", runtime.GOOS)
}
ln := newLocalListener(t).(*TCPListener) ln := newLocalListener(t).(*TCPListener)
defer ln.Close() defer ln.Close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment