Skip to content

Commit 8902562

Browse files
committed
[sourcekit] Fix a race in sourcekitdInProc's notification handling
Setting the notification handler was racing with calling it; now both happen on the same queue. Only affected the in-process sourcekitd.
1 parent a88c73f commit 8902562

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tools/SourceKit/tools/sourcekitd/bin/InProc/sourcekitdInProc.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,12 @@ sourcekitd_set_notification_handler(sourcekitd_response_receiver_t receiver) {
154154
}
155155

156156
void sourcekitd::postNotification(sourcekitd_response_t Notification) {
157-
sourcekitd_response_receiver_t receiver = Block_copy(NotificationReceiver);
158-
if (!receiver) {
159-
sourcekitd_response_dispose(Notification);
160-
return;
161-
}
162-
163157
WorkQueue::dispatchOnMain([=]{
158+
if (!NotificationReceiver) {
159+
sourcekitd_response_dispose(Notification);
160+
return;
161+
}
164162
// The receiver accepts ownership of the notification object.
165-
receiver(Notification);
166-
Block_release(receiver);
163+
NotificationReceiver(Notification);
167164
});
168165
}

0 commit comments

Comments
 (0)