Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
63386a10
Commit
63386a10
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
deduplicate server shutdown logic
parent
4aea5281
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/csharp/Grpc.Core/Server.cs
+28
-29
28 additions, 29 deletions
src/csharp/Grpc.Core/Server.cs
with
28 additions
and
29 deletions
src/csharp/Grpc.Core/Server.cs
+
28
−
29
View file @
63386a10
...
...
@@ -155,21 +155,9 @@ namespace Grpc.Core
/// <remarks>
/// It is strongly recommended to shutdown all previously created servers before exiting from the process.
/// </remarks>
public
async
Task
ShutdownAsync
()
public
Task
ShutdownAsync
()
{
lock
(
myLock
)
{
GrpcPreconditions
.
CheckState
(
startRequested
);
GrpcPreconditions
.
CheckState
(!
shutdownRequested
);
shutdownRequested
=
true
;
}
var
cq
=
environment
.
CompletionQueues
.
First
();
// any cq will do
handle
.
ShutdownAndNotify
(
HandleServerShutdown
,
cq
);
await
shutdownTcs
.
Task
.
ConfigureAwait
(
false
);
DisposeHandle
();
await
GrpcEnvironment
.
ReleaseAsync
().
ConfigureAwait
(
false
);
return
ShutdownInternalAsync
(
false
);
}
/// <summary>
...
...
@@ -179,22 +167,9 @@ namespace Grpc.Core
/// <remarks>
/// It is strongly recommended to shutdown all previously created servers before exiting from the process.
/// </remarks>
public
async
Task
KillAsync
()
public
Task
KillAsync
()
{
lock
(
myLock
)
{
GrpcPreconditions
.
CheckState
(
startRequested
);
GrpcPreconditions
.
CheckState
(!
shutdownRequested
);
shutdownRequested
=
true
;
}
var
cq
=
environment
.
CompletionQueues
.
First
();
// any cq will do
handle
.
ShutdownAndNotify
(
HandleServerShutdown
,
cq
);
handle
.
CancelAllCalls
();
await
shutdownTcs
.
Task
.
ConfigureAwait
(
false
);
DisposeHandle
();
await
GrpcEnvironment
.
ReleaseAsync
().
ConfigureAwait
(
false
);
return
ShutdownInternalAsync
(
true
);
}
internal
void
AddCallReference
(
object
call
)
...
...
@@ -212,6 +187,30 @@ namespace Grpc.Core
activeCallCounter
.
Decrement
();
}
/// <summary>
/// Shuts down the server.
/// </summary>
private
async
Task
ShutdownInternalAsync
(
bool
kill
)
{
lock
(
myLock
)
{
GrpcPreconditions
.
CheckState
(
startRequested
);
GrpcPreconditions
.
CheckState
(!
shutdownRequested
);
shutdownRequested
=
true
;
}
var
cq
=
environment
.
CompletionQueues
.
First
();
// any cq will do
handle
.
ShutdownAndNotify
(
HandleServerShutdown
,
cq
);
if
(
kill
)
{
handle
.
CancelAllCalls
();
}
await
shutdownTcs
.
Task
.
ConfigureAwait
(
false
);
DisposeHandle
();
await
GrpcEnvironment
.
ReleaseAsync
().
ConfigureAwait
(
false
);
}
/// <summary>
/// Adds a service definition.
/// </summary>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment