Skip to content

tests: Fix remaining race in gdbus-connection filter test

Commit 721e3855 left one remaining race in the filter test, with a comment associated with it. Unfortunately, the (seemingly unrelated) changes in #1841 (closed) to GCancellable seem to have made this remaining race a lot more likely to fail on FreeBSD than before.

What’s likely to have happened (although I was unable to reproduce the failure, due to not having a FreeBSD system; I was only able to reproduce the problem as a 3/1000 failure on Linux, which is still worth fixing) is that the atomic write of the FilterData.serial to be expected by the filter function sometimes happened after the filter function had executed, so the expected message was dropped and didn’t result in an update to the FilterData state.

Rework the test so that instead of setting some expectations (on FilterData) in one thread and then checking them in another thread, the worker thread just unconditionally returns messages from the filter function to the main thread, and then the main thread checks whether the expected one has been filtered.

With this change applied, the gdbus-connection test passes 5000 times in a row for me, on Linux; and doesn’t seem to fail any more on the FreeBSD CI machines over a few runs. (Previously it failed on 4/5 runs.)

Signed-off-by: Philip Withnall withnall@endlessm.com

Fixes: #2092 (closed) Fixes: #1957 (closed)

Merge request reports