Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
A
aspnetcore
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
dotnet
aspnetcore
提交
e15ea556
未验证
提交
e15ea556
编辑于
5 years ago
作者:
Brennan
提交者:
GitHub
5 years ago
浏览文件
操作
下载
补丁
差异文件
Cleanup when SendAsync with Upload stream (#13783)
上级
158d3f1c
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs
+7
-8
7 个添加, 8 个删除
src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs
src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs
+48
-1
48 个添加, 1 个删除
src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs
有
55 个添加
和
9 个删除
src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs
+
7
−
8
浏览文件 @
e15ea556
...
...
@@ -316,15 +316,9 @@ namespace Microsoft.AspNetCore.SignalR.Internal
_
=
StreamResultsAsync
(
hubMethodInvocationMessage
.
InvocationId
,
connection
,
enumerable
,
scope
,
hubActivator
,
hub
,
cts
,
hubMethodInvocationMessage
);
}
else
if
(
string
.
IsNullOrEmpty
(
hubMethodInvocationMessage
.
InvocationId
))
{
// Send Async, no response expected
invocation
=
ExecuteHubMethod
(
methodExecutor
,
hub
,
arguments
);
}
else
{
// Invoke
Async, one reponse expecte
d
// Invoke
or Sen
d
async
Task
ExecuteInvocation
()
{
object
result
;
...
...
@@ -350,7 +344,12 @@ namespace Microsoft.AspNetCore.SignalR.Internal
}
}
await
connection
.
WriteAsync
(
CompletionMessage
.
WithResult
(
hubMethodInvocationMessage
.
InvocationId
,
result
));
// No InvocationId - Send Async, no response expected
if
(!
string
.
IsNullOrEmpty
(
hubMethodInvocationMessage
.
InvocationId
))
{
// Invoke Async, one reponse expected
await
connection
.
WriteAsync
(
CompletionMessage
.
WithResult
(
hubMethodInvocationMessage
.
InvocationId
,
result
));
}
}
invocation
=
ExecuteInvocation
();
}
...
...
此差异已折叠。
点击以展开。
src/SignalR/server/SignalR/test/HubConnectionHandlerTests.cs
+
48
−
1
浏览文件 @
e15ea556
...
...
@@ -3402,6 +3402,46 @@ namespace Microsoft.AspNetCore.SignalR.Tests
}
}
[
Fact
]
public
async
Task
UploadStreamFromSendReleasesHubActivatorOnceComplete
()
{
using
(
StartVerifiableLog
())
{
var
serviceProvider
=
HubConnectionHandlerTestUtils
.
CreateServiceProvider
(
builder
=>
{
builder
.
AddSingleton
(
typeof
(
IHubActivator
<>),
typeof
(
CustomHubActivator
<>));
},
LoggerFactory
);
var
connectionHandler
=
serviceProvider
.
GetService
<
HubConnectionHandler
<
MethodHub
>>();
using
(
var
client
=
new
TestClient
())
{
var
connectionHandlerTask
=
await
client
.
ConnectAsync
(
connectionHandler
).
OrTimeout
();
var
hubActivator
=
serviceProvider
.
GetService
<
IHubActivator
<
MethodHub
>>()
as
CustomHubActivator
<
MethodHub
>;
var
createTask
=
hubActivator
.
CreateTask
.
Task
;
// null ID means we're doing a Send and not an Invoke
await
client
.
BeginUploadStreamAsync
(
invocationId
:
null
,
nameof
(
MethodHub
.
StreamingConcat
),
streamIds
:
new
[]
{
"id"
},
args
:
Array
.
Empty
<
object
>()).
OrTimeout
();
await
client
.
SendHubMessageAsync
(
new
StreamItemMessage
(
"id"
,
"hello"
)).
OrTimeout
();
await
client
.
SendHubMessageAsync
(
new
StreamItemMessage
(
"id"
,
" world"
)).
OrTimeout
();
await
createTask
.
OrTimeout
();
var
tcs
=
hubActivator
.
ReleaseTask
;
await
client
.
SendHubMessageAsync
(
CompletionMessage
.
Empty
(
"id"
)).
OrTimeout
();
await
tcs
.
Task
.
OrTimeout
();
// OnConnectedAsync and StreamingConcat hubs have been disposed
Assert
.
Equal
(
2
,
hubActivator
.
ReleaseCount
);
// Shut down
client
.
Dispose
();
await
connectionHandlerTask
.
OrTimeout
();
}
}
}
[
Fact
]
public
async
Task
UploadStreamClosesStreamsOnServerWhenMethodCompletes
()
{
...
...
@@ -3740,6 +3780,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{
public
int
ReleaseCount
;
private
IServiceProvider
_serviceProvider
;
public
TaskCompletionSource
<
object
>
ReleaseTask
=
new
TaskCompletionSource
<
object
>();
public
TaskCompletionSource
<
object
>
CreateTask
=
new
TaskCompletionSource
<
object
>();
public
CustomHubActivator
(
IServiceProvider
serviceProvider
)
{
...
...
@@ -3748,13 +3790,18 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public
THub
Create
()
{
return
new
DefaultHubActivator
<
THub
>(
_serviceProvider
).
Create
();
ReleaseTask
=
new
TaskCompletionSource
<
object
>();
var
hub
=
new
DefaultHubActivator
<
THub
>(
_serviceProvider
).
Create
();
CreateTask
.
TrySetResult
(
null
);
return
hub
;
}
public
void
Release
(
THub
hub
)
{
ReleaseCount
++;
hub
.
Dispose
();
ReleaseTask
.
TrySetResult
(
null
);
CreateTask
=
new
TaskCompletionSource
<
object
>();
}
}
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录