File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,24 @@ package syscall
2222
2323import (
2424 "net"
25+ "sync"
2526 "time"
2627
2728 "google.golang.org/grpc/grpclog"
2829)
2930
30- func init () {
31- grpclog .Info ("CPU time info is unavailable on non-linux or appengine environment." )
31+ var once sync.Once
32+
33+ func log () {
34+ once .Do (func () {
35+ grpclog .Info ("CPU time info is unavailable on non-linux or appengine environment." )
36+ })
3237}
3338
3439// GetCPUTime returns the how much CPU time has passed since the start of this process.
3540// It always returns 0 under non-linux or appengine environment.
3641func GetCPUTime () int64 {
42+ log ()
3743 return 0
3844}
3945
@@ -42,22 +48,26 @@ type Rusage struct{}
4248
4349// GetRusage is a no-op function under non-linux or appengine environment.
4450func GetRusage () (rusage * Rusage ) {
51+ log ()
4552 return nil
4653}
4754
4855// CPUTimeDiff returns the differences of user CPU time and system CPU time used
4956// between two Rusage structs. It a no-op function for non-linux or appengine environment.
5057func CPUTimeDiff (first * Rusage , latest * Rusage ) (float64 , float64 ) {
58+ log ()
5159 return 0 , 0
5260}
5361
5462// SetTCPUserTimeout is a no-op function under non-linux or appengine environments
5563func SetTCPUserTimeout (conn net.Conn , timeout time.Duration ) error {
64+ log ()
5665 return nil
5766}
5867
5968// GetTCPUserTimeout is a no-op function under non-linux or appengine environments
6069// a negative return value indicates the operation is not supported
6170func GetTCPUserTimeout (conn net.Conn ) (int , error ) {
71+ log ()
6272 return - 1 , nil
6373}
You can’t perform that action at this time.
0 commit comments