Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deadlock on solution close with linked files #17372

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,7 @@ protected void OnDocumentContextUpdated(DocumentId documentId)

if (container != null)
{
if (_isProjectUnloading.Value)
{
OnDocumentContextUpdated_NoSerializationLock(documentId, container);
}
else
{
OnDocumentContextUpdated(documentId, container);
}
OnDocumentContextUpdated(documentId, container);
}
}

Expand All @@ -345,10 +338,19 @@ protected void OnDocumentContextUpdated(DocumentId documentId)
/// </summary>
internal void OnDocumentContextUpdated(DocumentId documentId, SourceTextContainer container)
{
using (_serializationLock.DisposableWait())
if (_isProjectUnloading.Value)
{
// When the project is unloading, the serialization lock is already taken, so there
// is no need for us to take the lock since everything is already serialized.
OnDocumentContextUpdated_NoSerializationLock(documentId, container);
}
else
{
using (_serializationLock.DisposableWait())
{
OnDocumentContextUpdated_NoSerializationLock(documentId, container);
}
}
}

internal void OnDocumentContextUpdated_NoSerializationLock(DocumentId documentId, SourceTextContainer container)
Expand Down