|
1 | | -using System; |
2 | | -using System.Threading; |
3 | | -using System.Threading.Tasks; |
4 | | -using NetMQ.Sockets; |
| 1 | +using NetMQ.Sockets; |
5 | 2 | using Xunit; |
6 | 3 |
|
7 | 4 | namespace NetMQ.Tests |
@@ -285,40 +282,5 @@ public void SendMultipartMessageSucceeds() |
285 | 282 | Assert.Equal(new[] { "Hello", "Back" }, req.ReceiveMultipartStrings()); |
286 | 283 | } |
287 | 284 | } |
288 | | - |
289 | | - [Fact] |
290 | | - public async Task DisposedSocketDoesNotCauseInfiniteLoop() |
291 | | - { |
292 | | - // This test validates that when a socket is disposed while a send operation is in progress, |
293 | | - // it doesn't cause an infinite loop in TrySend. The fix ensures that Mailbox.TryRecv only |
294 | | - // catches SocketException and not ObjectDisposedException, allowing the exception to propagate |
295 | | - // and break out of the sending loop. |
296 | | - |
297 | | - var req = new RequestSocket(); |
298 | | - req.Options.Linger = TimeSpan.Zero; |
299 | | - |
300 | | - // Connect to an endpoint that has no peer - this will cause sends to block |
301 | | - req.Connect("tcp://localhost:15555"); |
302 | | - |
303 | | - // Dispose the socket to trigger ObjectDisposedException |
304 | | - req.Dispose(); |
305 | | - |
306 | | - // Create a task that will attempt to send on the disposed socket |
307 | | - // This should complete quickly by throwing an exception rather than hanging |
308 | | - var sendTask = Task.Run(() => |
309 | | - { |
310 | | - var msg = new NetMQMessage(); |
311 | | - msg.Append("test"); |
312 | | - req.SendMultipartMessage(msg); |
313 | | - }); |
314 | | - |
315 | | - // If the fix is working, this should complete quickly (within 5 seconds) |
316 | | - // If there's an infinite loop, it will timeout |
317 | | - // The task may complete with an exception (which is fine - we just want it to complete) |
318 | | - var timeoutTask = Task.Delay(TimeSpan.FromSeconds(5)); |
319 | | - var completedTask = await Task.WhenAny(sendTask, timeoutTask); |
320 | | - |
321 | | - Assert.True(completedTask == sendTask, "Send operation should complete quickly after disposal, not hang in infinite loop"); |
322 | | - } |
323 | 285 | } |
324 | 286 | } |
0 commit comments