Skip to content

Commit 7dd4515

Browse files
committed
tcp,udp,icmp: m rename SetAsTCPSockOpt/SetTimeoutSockOpt
1 parent 57eb9ae commit 7dd4515

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

intra/common.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,20 @@ func (h *baseHandler) forward(local, remote net.Conn, smm *SocketSummary) {
264264
isrwext := false
265265
iszerodeadline := false
266266
withsockopt := false
267+
timeoutsecs := 0
267268
// enable core.Pipe (sendfile/zero-copy) optimizations on TCP if
268269
// read & write deadlines are not set (as in rwext is effectively
269270
// a no-op) by unwrapping the underlying remote conn from rwext.
270271
if r, ok := remote.(rwext); ok {
271272
isrwext = true
272-
if r.IsZeroDeadline() {
273-
iszerodeadline = true
273+
if iszerodeadline = r.IsZeroDeadline(); iszerodeadline {
274274
remote = r.Unwrap()
275-
} else if r.SetAsTCPSockOpt() {
276-
withsockopt = true
275+
} else if timeoutsecs, withsockopt = r.SetTimeoutSockOpt(); withsockopt {
277276
remote = r.Unwrap() // c may be *net.TCPConn
278277
}
279278
}
280-
log.I("com: %s: forward: new conn %s rwext? %t, zerodeadline? %t, sockopt? %t; %s for %s",
281-
h.proto, via, isrwext, iszerodeadline, withsockopt, tup, uid)
279+
log.I("com: %s: forward: new conn %s rwext? %t, zerodeadline? %t, sockopt? %t (%ds); %s for %s",
280+
h.proto, via, isrwext, iszerodeadline, withsockopt, timeoutsecs, tup, uid)
282281

283282
uploadch := make(chan ioinfo)
284283

intra/rwconn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ func (rw rwext) IsZeroDeadline() bool {
2626
return r == 0 && w == 0
2727
}
2828

29-
func (rw rwext) SetAsTCPSockOpt() (didSet bool) {
29+
func (rw rwext) SetTimeoutSockOpt() (secs int, didSet bool) {
3030
r, w := rw.deadlines()
31-
timeoutSec := max(int(r), int(w))
31+
secs = max(int(r), int(w))
3232
if r > 0 {
3333
// always returns false for udp conns
34-
didSet = core.SetTimeoutSockOpt(rw.Unwrap(), timeoutSec*1000)
34+
didSet = core.SetTimeoutSockOpt(rw.Unwrap(), secs*1000)
3535
}
36-
return didSet
36+
return
3737
}
3838

3939
func (rw rwext) Unwrap() net.Conn {

0 commit comments

Comments
 (0)