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

[automated] Merge branch 'vs17.4' => 'vs17.5' #8562

Merged
merged 3 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.5.1</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<VersionPrefix>17.5.2</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.4.0</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
Expand Down
22 changes: 10 additions & 12 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ internal partial class LoggingService : ILoggingService, INodePacketHandler, IBu
/// <summary>
/// Event set when message is consumed from queue.
/// </summary>
private ManualResetEventSlim _dequeueEvent;
private AutoResetEvent _dequeueEvent;
/// <summary>
/// Event set when queue become empty.
/// </summary>
private ManualResetEventSlim _emptyQueueEvent;
private ManualResetEvent _emptyQueueEvent;
/// <summary>
/// Even set when message is added into queue.
/// </summary>
private ManualResetEventSlim _enqueueEvent;
private AutoResetEvent _enqueueEvent;

/// <summary>
/// CTS for stopping logging event processing.
Expand Down Expand Up @@ -1184,8 +1184,7 @@ internal virtual void ProcessLoggingEvent(object buildEvent)
while (_eventQueue.Count >= _queueCapacity)
{
// Block and wait for dequeue event.
_dequeueEvent.Wait();
_dequeueEvent.Reset();
_dequeueEvent.WaitOne();
}

_eventQueue.Enqueue(buildEvent);
Expand All @@ -1210,12 +1209,12 @@ public void WaitForLoggingToProcessEvents()
{
while (_eventQueue?.IsEmpty == false)
{
_emptyQueueEvent?.Wait();
_emptyQueueEvent?.WaitOne();
}
// To avoid race condition when last message has been removed from queue but
// not yet fully processed (handled by loggers), we need to make sure _emptyQueueEvent
// is set as it is guaranteed to be in set state no sooner than after event has been processed.
_emptyQueueEvent?.Wait();
_emptyQueueEvent?.WaitOne();
}

/// <summary>
Expand Down Expand Up @@ -1264,9 +1263,9 @@ private static int GetWarningsAsErrorOrMessageKey(BuildEventArgs buildEventArgs)
private void StartLoggingEventProcessing()
{
_eventQueue = new ConcurrentQueue<object>();
_dequeueEvent = new ManualResetEventSlim(false);
_emptyQueueEvent = new ManualResetEventSlim(false);
_enqueueEvent = new ManualResetEventSlim(false);
_dequeueEvent = new AutoResetEvent(false);
_emptyQueueEvent = new ManualResetEvent(false);
_enqueueEvent = new AutoResetEvent(false);
_loggingEventProcessingCancellation = new CancellationTokenSource();

_loggingEventProcessingThread = new Thread(LoggingEventProc);
Expand All @@ -1277,7 +1276,7 @@ private void StartLoggingEventProcessing()
void LoggingEventProc()
{
var completeAdding = _loggingEventProcessingCancellation.Token;
WaitHandle[] waitHandlesForNextEvent = { completeAdding.WaitHandle, _enqueueEvent.WaitHandle };
WaitHandle[] waitHandlesForNextEvent = { completeAdding.WaitHandle, _enqueueEvent };

do
{
Expand All @@ -1296,7 +1295,6 @@ void LoggingEventProc()
WaitHandle.WaitAny(waitHandlesForNextEvent);
}

_enqueueEvent.Reset();
_emptyQueueEvent.Reset();
}
} while (!_eventQueue.IsEmpty || !completeAdding.IsCancellationRequested);
Expand Down