SignalR有两个不同的分支,我想知道为什么其中一个在等待receiving,另一个没有。原因是什么?
else
{
// We're waiting on the websocket to close and there are 2 things it could be doing
// 1. Waiting for websocket data
// 2. Waiting on a flush to complete (backpressure being applied)
_aborted = true;
// Abort the websocket if we're stuck in a pending receive from the client
socket.Abort();
// Cancel any pending flush so that we can quit
_application.Output.CancelPendingFlush();
}vs
else
{
Log.WaitingForClose(_logger);
// We're waiting on the websocket to close and there are 2 things it could be doing
// 1. Waiting for websocket data
// 2. Waiting on a flush to complete (backpressure being applied)
using (var delayCts = new CancellationTokenSource())
{
var resultTask = await Task.WhenAny(receiving, Task.Delay(_options.CloseTimeout, delayCts.Token));
if (resultTask != receiving)
{
// Abort the websocket if we're stuck in a pending receive from the client
_aborted = true;
socket.Abort();
// Cancel any pending flush so that we can quit
_application.Output.CancelPendingFlush();
}
else
{
delayCts.Cancel();
}
}
}发布于 2022-04-11 07:12:48
他们在等待两种不同的东西:
第一分支处理1,第二分支处理2。
希望这些评论是解释性的。它们详细说明了任何一方可能被卡住的情况,以及我们因此而中止/取消的情况。
https://stackoverflow.com/questions/71544293
复制相似问题