Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
fe30ed2d
Commit
fe30ed2d
authored
Jan 24, 2012
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: actually reset deadline when time is zero
R=golang-dev, r CC=golang-dev
https://golang.org/cl/5570056
parent
0ae6084f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
src/pkg/net/sockopt.go
src/pkg/net/sockopt.go
+10
-2
src/pkg/net/timeout_test.go
src/pkg/net/timeout_test.go
+27
-0
No files found.
src/pkg/net/sockopt.go
View file @
fe30ed2d
...
...
@@ -117,12 +117,20 @@ func setWriteBuffer(fd *netFD, bytes int) error {
}
func
setReadDeadline
(
fd
*
netFD
,
t
time
.
Time
)
error
{
fd
.
rdeadline
=
t
.
UnixNano
()
if
t
.
IsZero
()
{
fd
.
rdeadline
=
0
}
else
{
fd
.
rdeadline
=
t
.
UnixNano
()
}
return
nil
}
func
setWriteDeadline
(
fd
*
netFD
,
t
time
.
Time
)
error
{
fd
.
wdeadline
=
t
.
UnixNano
()
if
t
.
IsZero
()
{
fd
.
wdeadline
=
0
}
else
{
fd
.
wdeadline
=
t
.
UnixNano
()
}
return
nil
}
...
...
src/pkg/net/timeout_test.go
View file @
fe30ed2d
...
...
@@ -77,3 +77,30 @@ func TestTimeoutTCP(t *testing.T) {
testTimeout
(
t
,
"tcp"
,
addr
,
false
)
<-
done
}
func
TestDeadlineReset
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
==
"plan9"
{
return
}
ln
,
err
:=
Listen
(
"tcp"
,
"127.0.0.1:0"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
ln
.
Close
()
tl
:=
ln
.
(
*
TCPListener
)
tl
.
SetDeadline
(
time
.
Now
()
.
Add
(
1
*
time
.
Minute
))
tl
.
SetDeadline
(
time
.
Time
{})
// reset it
errc
:=
make
(
chan
error
,
1
)
go
func
()
{
_
,
err
:=
ln
.
Accept
()
errc
<-
err
}()
select
{
case
<-
time
.
After
(
50
*
time
.
Millisecond
)
:
// Pass.
case
err
:=
<-
errc
:
// Accept should never return; we never
// connected to it.
t
.
Errorf
(
"unexpected return from Accept; err=%v"
,
err
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment