Skip to content

Commit 51aff46

Browse files
github-actions[bot]Erarndtrainersigwald
authored
[vs18.0] Exit DrainPacketQueue thread when build completes. (#12765)
Backport of #12561 to vs18.0 Work item (Internal use): [devdiv#2613541](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2613541) ### Summary MSBuild communications threads were incorrectly not exiting when builds completed. ### Customer Impact Memory leak that gets worse with each build or design-time build operation. ### Regression? Yes, from 17.14. ### Testing Unit tests, manual testing, already inserted into 18.3 builds. ### Risk Low. --------- Co-authored-by: Eric Arndt <[email protected]> Co-authored-by: Rainer Sigwald <[email protected]>
1 parent 149ded8 commit 51aff46

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Project>
44
<Import Project="Version.Details.props" Condition="Exists('Version.Details.props')" />
55
<PropertyGroup>
6-
<VersionPrefix>18.0.3</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
6+
<VersionPrefix>18.0.4</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
77
<PackageValidationBaselineVersion>17.14.8</PackageValidationBaselineVersion>
88
<AssemblyVersion>15.1.0.0</AssemblyVersion>
99
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>

src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ public NodeContext(
683683
// We select a thread size empirically - for debug builds the minimum possible stack size was too small.
684684
// The current size is reported to not have the issue.
685685
_drainPacketQueueThread = new Thread(DrainPacketQueue, 0x30000);
686+
_drainPacketQueueThread.Name = "DrainPacketQueueThread";
686687
_drainPacketQueueThread.IsBackground = true;
687688
_drainPacketQueueThread.Start(this);
688689
}
@@ -850,10 +851,13 @@ private void DrainPacketQueue(object state)
850851
serverToClientStream.Write(writeStreamBuffer, i, lengthToWrite);
851852
}
852853

853-
if (IsExitPacket(packet))
854+
if (packet is NodeBuildComplete)
854855
{
855-
context._exitPacketState = ExitPacketState.ExitPacketSent;
856-
context._packetQueueDrainDelayCancellation.Cancel();
856+
if (IsExitPacket(packet))
857+
{
858+
context._exitPacketState = ExitPacketState.ExitPacketSent;
859+
context._packetQueueDrainDelayCancellation.Cancel();
860+
}
857861

858862
return;
859863
}

0 commit comments

Comments
 (0)