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
3dbecd59
Commit
3dbecd59
authored
Dec 13, 2011
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
various: a grab-bag of time.Duration cleanups.
R=adg, r, rsc CC=golang-dev
https://golang.org/cl/5475069
parent
fc7b9fc2
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
30 additions
and
30 deletions
+30
-30
src/cmd/godoc/index.go
src/cmd/godoc/index.go
+2
-1
src/pkg/exp/inotify/inotify_linux_test.go
src/pkg/exp/inotify/inotify_linux_test.go
+3
-3
src/pkg/exp/norm/normregtest.go
src/pkg/exp/norm/normregtest.go
+1
-1
src/pkg/exp/winfsnotify/winfsnotify_test.go
src/pkg/exp/winfsnotify/winfsnotify_test.go
+2
-2
src/pkg/go/printer/printer_test.go
src/pkg/go/printer/printer_test.go
+1
-1
src/pkg/io/pipe_test.go
src/pkg/io/pipe_test.go
+1
-1
src/pkg/net/http/doc.go
src/pkg/net/http/doc.go
+2
-2
src/pkg/net/http/serve_test.go
src/pkg/net/http/serve_test.go
+1
-1
src/pkg/net/http/server.go
src/pkg/net/http/server.go
+7
-7
src/pkg/net/http/transport_test.go
src/pkg/net/http/transport_test.go
+1
-1
src/pkg/net/rpc/server_test.go
src/pkg/net/rpc/server_test.go
+3
-4
src/pkg/old/netchan/common.go
src/pkg/old/netchan/common.go
+2
-2
src/pkg/old/netchan/import.go
src/pkg/old/netchan/import.go
+1
-1
src/pkg/old/netchan/netchan_test.go
src/pkg/old/netchan/netchan_test.go
+3
-3
No files found.
src/cmd/godoc/index.go
View file @
3dbecd59
...
...
@@ -53,6 +53,7 @@ import (
"regexp"
"sort"
"strings"
"time"
)
// ----------------------------------------------------------------------------
...
...
@@ -767,7 +768,7 @@ func canonical(w string) string { return strings.ToLower(w) }
//
func
NewIndex
(
dirnames
<-
chan
string
,
fulltextIndex
bool
,
throttle
float64
)
*
Index
{
var
x
Indexer
th
:=
NewThrottle
(
throttle
,
0.1e9
)
// run at least 0.1s at a time
th
:=
NewThrottle
(
throttle
,
100
*
time
.
Millisecond
)
// run at least 0.1s at a time
// initialize Indexer
// (use some reasonably sized maps to start)
...
...
src/pkg/exp/inotify/inotify_linux_test.go
View file @
3dbecd59
...
...
@@ -57,7 +57,7 @@ func TestInotifyEvents(t *testing.T) {
}
// We expect this event to be received almost immediately, but let's wait 1 s to be sure
time
.
Sleep
(
1
000e6
)
// 1000 ms
time
.
Sleep
(
1
*
time
.
Second
)
if
eventsReceived
==
0
{
t
.
Fatal
(
"inotify event hasn't been received after 1 second"
)
}
...
...
@@ -69,7 +69,7 @@ func TestInotifyEvents(t *testing.T) {
select
{
case
<-
done
:
t
.
Log
(
"event channel closed"
)
case
<-
time
.
After
(
1
e9
)
:
case
<-
time
.
After
(
1
*
time
.
Second
)
:
t
.
Fatal
(
"event stream was not closed after 1 second"
)
}
}
...
...
@@ -84,7 +84,7 @@ func TestInotifyClose(t *testing.T) {
done
=
true
}()
time
.
Sleep
(
50
e6
)
// 50 ms
time
.
Sleep
(
50
*
time
.
Millisecond
)
if
!
done
{
t
.
Fatal
(
"double Close() test failed: second Close() call didn't return"
)
}
...
...
src/pkg/exp/norm/normregtest.go
View file @
3dbecd59
...
...
@@ -285,7 +285,7 @@ func PerformanceTest() {
norm
.
NFC
.
Append
(
nil
,
buf
...
)
success
<-
true
}()
timeout
:=
time
.
After
(
1
e9
)
timeout
:=
time
.
After
(
1
*
time
.
Second
)
select
{
case
<-
success
:
// test completed before the timeout
...
...
src/pkg/exp/winfsnotify/winfsnotify_test.go
View file @
3dbecd59
...
...
@@ -21,7 +21,7 @@ func expect(t *testing.T, eventstream <-chan *Event, name string, mask uint32) {
if
event
.
Name
!=
name
||
event
.
Mask
!=
mask
{
t
.
Fatal
(
"did not receive expected event"
)
}
case
<-
time
.
After
(
1
e9
)
:
case
<-
time
.
After
(
1
*
time
.
Second
)
:
t
.
Fatal
(
"timed out waiting for event"
)
}
}
...
...
@@ -108,7 +108,7 @@ func TestNotifyClose(t *testing.T) {
done
=
true
}()
time
.
Sleep
(
50
e6
)
// 50 ms
time
.
Sleep
(
50
*
time
.
Millisecond
)
if
!
done
{
t
.
Fatal
(
"double Close() test failed: second Close() call didn't return"
)
}
...
...
src/pkg/go/printer/printer_test.go
View file @
3dbecd59
...
...
@@ -107,7 +107,7 @@ func check(t *testing.T, source, golden string, mode checkMode) {
// start a timer to produce a time-out signal
tc
:=
make
(
chan
int
)
go
func
()
{
time
.
Sleep
(
10
e9
)
// plenty of a safety margin, even for very slow machines
time
.
Sleep
(
10
*
time
.
Second
)
// plenty of a safety margin, even for very slow machines
tc
<-
0
}()
...
...
src/pkg/io/pipe_test.go
View file @
3dbecd59
...
...
@@ -165,7 +165,7 @@ var pipeTests = []pipeTest{
}
func
delayClose
(
t
*
testing
.
T
,
cl
closer
,
ch
chan
int
,
tt
pipeTest
)
{
time
.
Sleep
(
1
e6
)
// 1 ms
time
.
Sleep
(
1
*
time
.
Millisecond
)
var
err
error
if
tt
.
closeWithError
{
err
=
cl
.
CloseWithError
(
tt
.
err
)
...
...
src/pkg/net/http/doc.go
View file @
3dbecd59
...
...
@@ -70,8 +70,8 @@ custom Server:
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10
e9
,
WriteTimeout: 10
e9
,
ReadTimeout: 10
* time.Second
,
WriteTimeout: 10
* time.Second
,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(s.ListenAndServe())
...
...
src/pkg/net/http/serve_test.go
View file @
3dbecd59
...
...
@@ -538,7 +538,7 @@ func TestHeadResponses(t *testing.T) {
func
TestTLSHandshakeTimeout
(
t
*
testing
.
T
)
{
ts
:=
httptest
.
NewUnstartedServer
(
HandlerFunc
(
func
(
w
ResponseWriter
,
r
*
Request
)
{}))
ts
.
Config
.
ReadTimeout
=
250
e6
ts
.
Config
.
ReadTimeout
=
250
*
time
.
Millisecond
ts
.
StartTLS
()
defer
ts
.
Close
()
conn
,
err
:=
net
.
Dial
(
"tcp"
,
ts
.
Listener
.
Addr
()
.
String
())
...
...
src/pkg/net/http/server.go
View file @
3dbecd59
...
...
@@ -952,11 +952,11 @@ func Serve(l net.Listener, handler Handler) error {
// A Server defines parameters for running an HTTP server.
type
Server
struct
{
Addr
string
// TCP address to listen on, ":http" if empty
Handler
Handler
// handler to invoke, http.DefaultServeMux if nil
ReadTimeout
int64
// the net.Conn.SetReadTimeout value for new connections
WriteTimeout
int64
// the net.Conn.SetWriteTimeout value for new connections
MaxHeaderBytes
int
// maximum size of request headers, DefaultMaxHeaderBytes if 0
Addr
string
// TCP address to listen on, ":http" if empty
Handler
Handler
// handler to invoke, http.DefaultServeMux if nil
ReadTimeout
time
.
Duration
// the net.Conn.SetReadTimeout value for new connections
WriteTimeout
time
.
Duration
// the net.Conn.SetWriteTimeout value for new connections
MaxHeaderBytes
int
// maximum size of request headers, DefaultMaxHeaderBytes if 0
}
// ListenAndServe listens on the TCP network address srv.Addr and then
...
...
@@ -989,10 +989,10 @@ func (srv *Server) Serve(l net.Listener) error {
return
e
}
if
srv
.
ReadTimeout
!=
0
{
rw
.
SetReadTimeout
(
srv
.
ReadTimeout
)
rw
.
SetReadTimeout
(
srv
.
ReadTimeout
.
Nanoseconds
()
)
}
if
srv
.
WriteTimeout
!=
0
{
rw
.
SetWriteTimeout
(
srv
.
WriteTimeout
)
rw
.
SetWriteTimeout
(
srv
.
WriteTimeout
.
Nanoseconds
()
)
}
c
,
err
:=
srv
.
newConn
(
rw
)
if
err
!=
nil
{
...
...
src/pkg/net/http/transport_test.go
View file @
3dbecd59
...
...
@@ -292,7 +292,7 @@ func TestTransportServerClosingUnexpectedly(t *testing.T) {
// it on most fast machines, causing the next fetch() call to
// succeed quickly. But if we do get errors, fetch() will retry 5
// times with some delays between.
time
.
Sleep
(
25
e6
)
time
.
Sleep
(
25
*
time
.
Millisecond
)
body3
:=
fetch
(
3
,
5
)
...
...
src/pkg/net/rpc/server_test.go
View file @
3dbecd59
...
...
@@ -27,7 +27,6 @@ var (
)
const
(
second
=
1e9
newHttpPath
=
"/foo"
)
...
...
@@ -388,12 +387,12 @@ func (WriteFailCodec) WriteRequest(*Request, interface{}) error {
}
func
(
WriteFailCodec
)
ReadResponseHeader
(
*
Response
)
error
{
time
.
Sleep
(
120
e9
)
time
.
Sleep
(
120
*
time
.
Second
)
panic
(
"unreachable"
)
}
func
(
WriteFailCodec
)
ReadResponseBody
(
interface
{})
error
{
time
.
Sleep
(
120
e9
)
time
.
Sleep
(
120
*
time
.
Second
)
panic
(
"unreachable"
)
}
...
...
@@ -413,7 +412,7 @@ func TestSendDeadlock(t *testing.T) {
select
{
case
<-
done
:
return
case
<-
time
.
After
(
5
e9
)
:
case
<-
time
.
After
(
5
*
time
.
Second
)
:
t
.
Fatal
(
"deadlock"
)
}
}
...
...
src/pkg/old/netchan/common.go
View file @
3dbecd59
...
...
@@ -155,7 +155,7 @@ func (cs *clientSet) drain(timeout time.Duration) error {
if
timeout
>
0
&&
time
.
Now
()
.
After
(
deadline
)
{
return
errors
.
New
(
"timeout"
)
}
time
.
Sleep
(
100
*
1e6
)
// 100 milliseconds
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
nil
}
...
...
@@ -188,7 +188,7 @@ func (cs *clientSet) sync(timeout time.Duration) error {
if
timeout
>
0
&&
time
.
Now
()
.
After
(
deadline
)
{
return
errors
.
New
(
"timeout"
)
}
time
.
Sleep
(
100
*
1e6
)
// 100 milliseconds
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
nil
}
...
...
src/pkg/old/netchan/import.go
View file @
3dbecd59
...
...
@@ -281,7 +281,7 @@ func (imp *Importer) Drain(timeout int64) error {
if
timeout
>
0
&&
time
.
Now
()
.
After
(
deadline
)
{
return
errors
.
New
(
"timeout"
)
}
time
.
Sleep
(
100
*
1e6
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
nil
}
src/pkg/old/netchan/netchan_test.go
View file @
3dbecd59
...
...
@@ -151,7 +151,7 @@ func TestErrorForIllegalChannel(t *testing.T) {
// Expect an error now. Start a timeout.
timeout
:=
make
(
chan
bool
,
1
)
// buffered so closure will not hang around.
go
func
()
{
time
.
Sleep
(
10
e9
)
// very long, to give even really slow machines a chance.
time
.
Sleep
(
10
*
time
.
Second
)
// very long, to give even really slow machines a chance.
timeout
<-
true
}()
select
{
...
...
@@ -300,7 +300,7 @@ func TestIndependentSends(t *testing.T) {
go
importReceive
(
imp
,
t
,
done
)
// wait for export side to try to deliver some values.
time
.
Sleep
(
0.25e9
)
time
.
Sleep
(
250
*
time
.
Millisecond
)
ctlch
:=
make
(
chan
int
)
if
err
:=
imp
.
ImportNValues
(
"exportedCtl"
,
ctlch
,
Send
,
1
,
1
);
err
!=
nil
{
...
...
@@ -409,7 +409,7 @@ func TestImportFlowControl(t *testing.T) {
func
testFlow
(
sendDone
chan
bool
,
ch
<-
chan
int
,
N
int
,
t
*
testing
.
T
)
{
go
func
()
{
time
.
Sleep
(
0.5e9
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
sendDone
<-
false
}()
...
...
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