// used on operating systems where the deadline hasn't been pushed
// 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) {
- var timeout time.Duration
- if !deadline.IsZero() {
- timeout = deadline.Sub(time.Now())
+ if deadline.IsZero() {
+ return dialer(noDeadline)
}
+ timeout := deadline.Sub(time.Now())
if timeout <= 0 {
- return dialer(noDeadline)
+ return nil, &OpError{Op: "dial", Net: net, Addr: ra, Err: errTimeout}
}
t := time.NewTimer(timeout)
defer t.Stop()
// TestConnectDeadlineInThePast tests that connect deadlines work, even
// if the connection can be established w/o blocking.
func TestConnectDeadlineInThePast(t *testing.T) {
- switch runtime.GOOS {
- case "plan9":
- t.Skipf("skipping test on %q", runtime.GOOS)
- }
-
ln := newLocalListener(t).(*TCPListener)
defer ln.Close()