Roll forward up to cl/353292511.

This commit is contained in:
hai007
2021-01-22 12:13:44 -08:00
parent 524bd1d2f3
commit 335b3a8d45
36 changed files with 592 additions and 155 deletions
+24 -2
View File
@@ -146,6 +146,10 @@ void ServiceControllerRouter::RequestConnection(
ClientProxy* client, absl::string_view endpoint_id,
const ConnectionRequestInfo& info, const ConnectionOptions& options,
const ResultCallback& callback) {
// Cancellations can be fired from clients anytime, need to add the
// CancellationListener as soon as possible.
client->AddCancellationFlag(std::string(endpoint_id));
RouteToServiceController([this, client,
endpoint_id = std::string(endpoint_id), info,
options, callback]() {
@@ -160,8 +164,12 @@ void ServiceControllerRouter::RequestConnection(
return;
}
callback.result_cb(service_controller_->RequestConnection(
client, endpoint_id, info, options));
Status status = service_controller_->RequestConnection(client, endpoint_id,
info, options);
if (!status.Ok()) {
client->CancelEndpoint(endpoint_id);
}
callback.result_cb(status);
});
}
@@ -199,6 +207,8 @@ void ServiceControllerRouter::AcceptConnection(ClientProxy* client,
void ServiceControllerRouter::RejectConnection(ClientProxy* client,
absl::string_view endpoint_id,
const ResultCallback& callback) {
client->CancelEndpoint(std::string(endpoint_id));
RouteToServiceController(
[this, client, endpoint_id = std::string(endpoint_id), callback]() {
if (!ClientHasAcquiredServiceController(client)) {
@@ -296,6 +306,10 @@ void ServiceControllerRouter::CancelPayload(ClientProxy* client,
void ServiceControllerRouter::DisconnectFromEndpoint(
ClientProxy* client, absl::string_view endpoint_id,
const ResultCallback& callback) {
// Client can emit the cancellation at anytime, we need to execute the request
// without further posting it.
client->CancelEndpoint(std::string(endpoint_id));
RouteToServiceController(
[this, client, endpoint_id = std::string(endpoint_id), callback]() {
if (ClientHasAcquiredServiceController(client)) {
@@ -312,6 +326,10 @@ void ServiceControllerRouter::DisconnectFromEndpoint(
void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client,
const ResultCallback& callback) {
// Client can emit the cancellation at anytime, we need to execute the request
// without further posting it.
client->CancelAllEndpoints();
RouteToServiceController([this, client, callback]() {
if (ClientHasAcquiredServiceController(client)) {
DoneWithStrategySessionForClient(client);
@@ -322,6 +340,10 @@ void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client,
void ServiceControllerRouter::ClientDisconnecting(
ClientProxy* client, const ResultCallback& callback) {
// Client can emit the cancellation at anytime, we need to execute the request
// without further posting it.
client->CancelAllEndpoints();
RouteToServiceController([this, client, callback]() {
if (ClientHasAcquiredServiceController(client)) {
DoneWithStrategySessionForClient(client);