Skip to content

Commit 9cc3016

Browse files
committed
syscall: remove logging in init().
Signed-off-by: Yangmin Zhu <[email protected]>
1 parent f1437f7 commit 9cc3016

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: internal/syscall/syscall_nonlinux.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,24 @@ package syscall
2222

2323
import (
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.
3641
func 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.
4450
func 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.
5057
func 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
5563
func 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
6170
func GetTCPUserTimeout(conn net.Conn) (int, error) {
71+
log()
6272
return -1, nil
6373
}

0 commit comments

Comments
 (0)