Skip to content

Commit b65d3ff

Browse files
committed
icmp: m goroutine calls into kotlin listener
1 parent 8134609 commit b65d3ff

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

intra/icmp.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,19 @@ func (h *icmpHandler) Ping(msg []byte, source, target netip.AddrPort) (echoed bo
117117
h.conntracker.Track(cid, uid, pidstr(px), uc)
118118
defer h.conntracker.Untrack(cid)
119119

120-
h.listener.PostFlow(smm.postMark())
120+
awaited := core.Await(func() {
121+
h.listener.PostFlow(smm.postMark())
122+
}, onFlowTimeout)
121123

122124
tx = len(msg)
123125
// todo: construct ICMP header? github.com/prometheus-community/pro-bing/blob/0bacb2d5e7/ping.go#L717
124126
reply, from, err := core.Echo(uc, msg, net.UDPAddrFromAddrPort(dst), target.Addr().Is4())
125127
rx = len(reply)
126128
rtt = time.Since(rttstart)
127129
// todo: ignore non-ICMP replies in b: github.com/prometheus-community/pro-bing/blob/0bacb2d5e7/ping.go#L630
128-
logev(err)("t.icmp: ingress: read(%v <= %v / %v) ping done (send: %d, recv: %d, rtt: %s); err? %v",
129-
source, from, dst, tx, rx, core.FmtPeriod(rtt), err)
130+
logev(err)("t.icmp: ingress: read(%v <= %v / %v) ping done (send: %d, recv: %d, rtt: %s); postflow? %t; err? %v",
131+
source, from, dst, tx, rx, core.FmtPeriod(rtt), awaited, err)
130132

131-
return true // echoed; even if err != nil
133+
// TODO: on timeout errs, return false?
134+
return true // echoed
132135
}

0 commit comments

Comments
 (0)