Skip to content

Commit 0f8d3e6

Browse files
authored
Fix a little thinko in sending events to secondary listeners. (#71997)
If `unique` is true, I was redoing the uniqueness check for the secondary listeners, which is racy since a "duplicate" event could come in between deciding to send the event to the main listener and checking for the shadow listener, and then the two streams would get out of sync. There's not a good way to write a direct test for this, but the test_shadow_listeners test has been flakey and this is the only racy part of that system I can find. So the test would be that that test_shadow_listeners becomes not flakey.
1 parent 64f62de commit 0f8d3e6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lldb/source/Utility/Broadcaster.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(EventSP &event_sp,
280280
// Make sure to do this before adding the event to the primary or it might
281281
// start handling the event before we're done adding all the pending
282282
// listeners.
283+
// Also, don't redo the check for unique here, since otherwise that could
284+
// be racy, and if we send the event to the primary listener then we SHOULD
285+
// send it to the secondary listeners or they will get out of sync with the
286+
// primary listener.
283287
if (!hijacking_listener_sp) {
284-
for (auto &pair : GetListeners(event_type, false)) {
285-
if (unique && pair.first->PeekAtNextEventForBroadcasterWithType(
286-
&m_broadcaster, event_type))
287-
continue;
288+
for (auto &pair : GetListeners(event_type, false))
288289
event_sp->AddPendingListener(pair.first);
289-
}
290290
}
291291
primary_listener_sp->AddEvent(event_sp);
292292
} else {

0 commit comments

Comments
 (0)