Skip to content

Commit 81d313b

Browse files
Copilotdrewnoakes
andauthored
Add macOS CI job and regression test for Cleanup(block: false) bounded time
Agent-Logs-Url: https://github.com/zeromq/netmq/sessions/18a93bf8-a14c-4c0d-9f27-b797b58f300f Co-authored-by: drewnoakes <[email protected]>
1 parent 22ba70d commit 81d313b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/CI.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ jobs:
1515
run: dotnet build src/NetMQ.sln /p:Configuration=Release /verbosity:minimal
1616
- name: test net10.0
1717
run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net10.0 src/NetMQ.Tests/NetMQ.Tests.csproj
18+
macos:
19+
runs-on: macos-latest
20+
permissions:
21+
contents: read
22+
env:
23+
DOTNET_NOLOGO: true
24+
steps:
25+
- uses: actions/checkout@v6
26+
- uses: actions/setup-dotnet@v5
27+
with:
28+
dotnet-version: 10.0.x
29+
- run: dotnet restore src/NetMQ.sln
30+
- name: build
31+
run: dotnet build src/NetMQ.sln /p:Configuration=Release /verbosity:minimal
32+
- name: test net10.0
33+
run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net10.0 src/NetMQ.Tests/NetMQ.Tests.csproj
1834
windows:
1935
runs-on: windows-latest
2036
env:

src/NetMQ.Tests/CleanupTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Threading;
34
using NetMQ.Sockets;
45
using Xunit;
56

@@ -62,5 +63,21 @@ public void NoBlockNoDispose()
6263

6364
NetMQConfig.Cleanup(block: false);
6465
}
66+
67+
[Fact]
68+
public void NoBlockCompletesInBoundedTime()
69+
{
70+
// Regression test for https://github.com/zeromq/netmq/issues/1040
71+
// Cleanup(block: false) must return quickly even when a socket has not been
72+
// disposed and the internal poller is actively calling Socket.Select.
73+
// On macOS, Socket.Select can block indefinitely when passed both a read list
74+
// and an error list, causing Cleanup to hang forever without this guard.
75+
_ = new DealerSocket(">tcp://localhost:5557"); // intentionally not disposed
76+
77+
var thread = new Thread(() => NetMQConfig.Cleanup(block: false));
78+
thread.Start();
79+
Assert.True(thread.Join(TimeSpan.FromSeconds(10)),
80+
"Cleanup(block: false) did not complete within 10 seconds");
81+
}
6582
}
6683
}

0 commit comments

Comments
 (0)