Skip to content

linux: deliver D-Bus signals in order - #525

Open
Moret84 wants to merge 1 commit into
tinygo-org:devfrom
CrossoverTechnologies:linux-ordered-notifications
Open

Moret84 wants to merge 1 commit into
tinygo-org:devfrom
CrossoverTechnologies:linux-ordered-notifications

Conversation

@Moret84

@Moret84 Moret84 commented Oct 30, 2026 •

Copy link
Copy Markdown

On Linux, GATT notifications can reach the notification callback out of order. dbus.SystemBus uses the default godbus signal handler, which hands a signal to a new goroutine when the channel is busy, so a later signal can arrive first (default_handler.go). Protocols that split a message over several notifications, such as Bluetooth Mesh proxy SAR, then rebuild a corrupt message.

Enable now opens its own shared system bus connection with the sequential signal handler, which keeps the bus order per channel. A program that also calls dbus.SystemBus now gets a second connection.

TestNotificationsInOrder runs a minimal D-Bus server on a unix socket, without BlueZ, and sends 1000 numbered notifications. It failed 50 runs out of 50 with the default handler and passes 50 out of 50 with the fix, and 20 out of 20 with -race. make smoketest-linux passes.

dbus.SystemBus uses the default godbus signal handler. When a signal
channel is busy, it hands the signal to a new goroutine, so a later
signal can reach the channel first. Notifications are PropertiesChanged
signals, so they could be reported out of order. Protocols that split a
message over several notifications, such as Bluetooth Mesh proxy SAR,
then rebuild a corrupt message.

Enable now uses a shared system bus connection of its own, made with the
sequential signal handler, which queues the signals of each channel in
the order they are read from the bus.

The test runs a minimal bus that sends a burst of notifications.
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