Skip to content

Commit cb3a84c

Browse files
committed
Ensure RemoteInvokeHandle is disposed
1 parent 6575440 commit cb3a84c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketDuplicationTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,16 @@ public async Task DuplicateAndClose_TcpServerHandler(AddressFamily addressFamily
330330
else
331331
{
332332
RemoteInvokeHandle hServerProc = RemoteExecutor.Invoke(HandlerServerCode, _ipcPipeName);
333-
await RunCommonHostLogic(hServerProc.Process.Id);
334-
await hServerProc.DisposeAsync();
333+
334+
// Since RunCommonHostLogic can throw, we need to make sure the server process is disposed
335+
try
336+
{
337+
await RunCommonHostLogic(hServerProc.Process.Id);
338+
}
339+
finally
340+
{
341+
await hServerProc.DisposeAsync();
342+
}
335343
}
336344

337345
async Task RunCommonHostLogic(int processId)

0 commit comments

Comments
 (0)