detached fe90d45

fix(quicnettest): emit the impairment event before scheduling the packet

A zero-latency packet could be delivered and answered before ingest emitted its event, so the reply's event was observed first.
commit
fe90d45828e97e53992daf093bcfca0bf8a8b812
author
brice · · 2026-10-08 08:07 UTC
parent
dce3fad
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
refs
fix/ci-race-and-proxy-event-order
1 file · +11 -8
M internal/adapters/quicnettest/proxy.go +11 -8
@@ -468,6 +468,17 @@ func (p *Proxy) ingest(toServer bool, raw []byte, dst *net.UDPAddr) {
468468 counters.reordered.Add(1)
469469 }
470470 due := now.Add(link.BaseLatency + decision.ExtraDelay)
471+ // Emit before scheduling: once enqueued, a zero-latency copy can be
472+ // delivered and answered before this call returns, and the reply's event
473+ // must not be observed ahead of the packet that caused it.
474+ p.emit(Event{
475+ Direction: directionOf(toServer),
476+ Sequence: seq,
477+ Bytes: len(raw),
478+ At: now,
479+ Due: due,
480+ Decision: decision,
481+ })
471482 for copyIndex := 0; copyIndex <= decision.Duplicates; copyIndex++ {
472483 copyDue := due.Add(time.Duration(copyIndex) * link.DuplicateDelay)
473484 if !p.enqueue(packet{
@@ -480,14 +491,6 @@ func (p *Proxy) ingest(toServer bool, raw []byte, dst *net.UDPAddr) {
480491 counters.overflowDrops.Add(1)
481492 }
482493 }
483- p.emit(Event{
484- Direction: directionOf(toServer),
485- Sequence: seq,
486- Bytes: len(raw),
487- At: now,
488- Due: due,
489- Decision: decision,
490- })
491494 }
492495
493496 func (p *Proxy) enqueue(pkt packet) bool {
@@ -468,6 +468,17 @@ func (p *Proxy) ingest(toServer bool, raw []byte, dst *net.UDPAddr) {
468 counters.reordered.Add(1)468 counters.reordered.Add(1)
469 }469 }
470 due := now.Add(link.BaseLatency + decision.ExtraDelay)470 due := now.Add(link.BaseLatency + decision.ExtraDelay)
471+ // Emit before scheduling: once enqueued, a zero-latency copy can be
472+ // delivered and answered before this call returns, and the reply's event
473+ // must not be observed ahead of the packet that caused it.
474+ p.emit(Event{
475+ Direction: directionOf(toServer),
476+ Sequence: seq,
477+ Bytes: len(raw),
478+ At: now,
479+ Due: due,
480+ Decision: decision,
481+ })
471 for copyIndex := 0; copyIndex <= decision.Duplicates; copyIndex++ {482 for copyIndex := 0; copyIndex <= decision.Duplicates; copyIndex++ {
472 copyDue := due.Add(time.Duration(copyIndex) * link.DuplicateDelay)483 copyDue := due.Add(time.Duration(copyIndex) * link.DuplicateDelay)
473 if !p.enqueue(packet{484 if !p.enqueue(packet{
@@ -480,14 +491,6 @@ func (p *Proxy) ingest(toServer bool, raw []byte, dst *net.UDPAddr) {
480 counters.overflowDrops.Add(1)491 counters.overflowDrops.Add(1)
481 }492 }
482 }493 }
483- p.emit(Event{
484- Direction: directionOf(toServer),
485- Sequence: seq,
486- Bytes: len(raw),
487- At: now,
488- Due: due,
489- Decision: decision,
490- })
491 }494 }
492 495
493 func (p *Proxy) enqueue(pkt packet) bool {496 func (p *Proxy) enqueue(pkt packet) bool {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close