Skip to content

route targeted messages to all matching channels - #196

Open
serhii-matsyshyn wants to merge 1 commit into
bluenviron:mainfrom
serhii-matsyshyn:main
Open

route targeted messages to all matching channels#196
serhii-matsyshyn wants to merge 1 commit into
bluenviron:mainfrom
serhii-matsyshyn:main

Conversation

@serhii-matsyshyn

Copy link
Copy Markdown

Problem

Both lookup helpers return &key from inside for key := range m.remoteNodes,
so they yield whichever match Go's randomised map iteration reaches first. When
several nodes match a target, the frame goes to one and is silently dropped for
the rest — no error, no log, the sender just never gets an answer. Several nodes
match with target_component = 0 (resolved on system ID alone) and with a
companion computer sharing the vehicle's system ID: measured on a drone, 13 % of
GCS-to-autopilot requests lost before, 0 % after.

Change

Resolve to every matching channel, deduplicated, and write to each except the
sender. Fallbacks untouched. Also takes remoteNodeMutex during lookup — the
helpers ranged over remoteNodes while the cleanup goroutine deletes under it, a
fatal concurrent map iteration and map write. Happy to split that out.

Tests

TestRouteMultipleChannels and TestRouteMultipleChannelsComponentZero fail on
main and pass with the change. TestRouteSameChannelOnce and TestRouteToItself
pass either way, pinning behaviour that must not change. gofmt, go vet and
go test -race ./... clean.

Side finding

FixFrame replaces fr.Message with a MessageRaw, so getTarget's reflection finds
no target fields and the frame takes the broadcast path. TestRouteSingle and
TestRouteAll both call it before ProcessFrame, so neither has been exercising
targeted routing — likely how this survived. The new test helper restores the
typed message after FixFrame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant