|
|
@ -151,19 +151,25 @@ class Server::SyncRequest final : public CompletionQueueTag { |
|
|
|
GPR_ASSERT(cq_ && !in_flight_); |
|
|
|
GPR_ASSERT(cq_ && !in_flight_); |
|
|
|
in_flight_ = true; |
|
|
|
in_flight_ = true; |
|
|
|
if (tag_) { |
|
|
|
if (tag_) { |
|
|
|
GPR_ASSERT(GRPC_CALL_OK == |
|
|
|
if (GRPC_CALL_OK != |
|
|
|
grpc_server_request_registered_call( |
|
|
|
grpc_server_request_registered_call( |
|
|
|
server, tag_, &call_, &deadline_, &request_metadata_, |
|
|
|
server, tag_, &call_, &deadline_, &request_metadata_, |
|
|
|
has_request_payload_ ? &request_payload_ : nullptr, cq_, |
|
|
|
has_request_payload_ ? &request_payload_ : nullptr, cq_, |
|
|
|
notify_cq, this)); |
|
|
|
notify_cq, this)) { |
|
|
|
|
|
|
|
TeardownRequest(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!call_details_) { |
|
|
|
if (!call_details_) { |
|
|
|
call_details_ = new grpc_call_details; |
|
|
|
call_details_ = new grpc_call_details; |
|
|
|
grpc_call_details_init(call_details_); |
|
|
|
grpc_call_details_init(call_details_); |
|
|
|
} |
|
|
|
} |
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( |
|
|
|
if (grpc_server_request_call(server, &call_, call_details_, |
|
|
|
server, &call_, call_details_, |
|
|
|
&request_metadata_, cq_, notify_cq, |
|
|
|
&request_metadata_, cq_, notify_cq, this)); |
|
|
|
this) != GRPC_CALL_OK) { |
|
|
|
|
|
|
|
TeardownRequest(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -286,12 +292,10 @@ class Server::SyncRequestThreadManager : public ThreadManager { |
|
|
|
if (ok) { |
|
|
|
if (ok) { |
|
|
|
// Calldata takes ownership of the completion queue inside sync_req
|
|
|
|
// Calldata takes ownership of the completion queue inside sync_req
|
|
|
|
SyncRequest::CallData cd(server_, sync_req); |
|
|
|
SyncRequest::CallData cd(server_, sync_req); |
|
|
|
{ |
|
|
|
// Prepare for the next request
|
|
|
|
// Prepare for the next request
|
|
|
|
if (!IsShutdown()) { |
|
|
|
if (!IsShutdown()) { |
|
|
|
sync_req->SetupRequest(); // Create new completion queue for sync_req
|
|
|
|
sync_req->SetupRequest(); // Create new completion queue for sync_req
|
|
|
|
sync_req->Request(server_->c_server(), server_cq_->cq()); |
|
|
|
sync_req->Request(server_->c_server(), server_cq_->cq()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GPR_TIMER_SCOPE("cd.Run()", 0); |
|
|
|
GPR_TIMER_SCOPE("cd.Run()", 0); |
|
|
@ -316,8 +320,8 @@ class Server::SyncRequestThreadManager : public ThreadManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Shutdown() override { |
|
|
|
void Shutdown() override { |
|
|
|
server_cq_->Shutdown(); |
|
|
|
|
|
|
|
ThreadManager::Shutdown(); |
|
|
|
ThreadManager::Shutdown(); |
|
|
|
|
|
|
|
server_cq_->Shutdown(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Wait() override { |
|
|
|
void Wait() override { |
|
|
@ -652,10 +656,11 @@ ServerInterface::RegisteredAsyncRequest::RegisteredAsyncRequest( |
|
|
|
void ServerInterface::RegisteredAsyncRequest::IssueRequest( |
|
|
|
void ServerInterface::RegisteredAsyncRequest::IssueRequest( |
|
|
|
void* registered_method, grpc_byte_buffer** payload, |
|
|
|
void* registered_method, grpc_byte_buffer** payload, |
|
|
|
ServerCompletionQueue* notification_cq) { |
|
|
|
ServerCompletionQueue* notification_cq) { |
|
|
|
grpc_server_request_registered_call( |
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_registered_call( |
|
|
|
server_->server(), registered_method, &call_, &context_->deadline_, |
|
|
|
server_->server(), registered_method, &call_, |
|
|
|
context_->client_metadata_.arr(), payload, call_cq_->cq(), |
|
|
|
&context_->deadline_, |
|
|
|
notification_cq->cq(), this); |
|
|
|
context_->client_metadata_.arr(), payload, |
|
|
|
|
|
|
|
call_cq_->cq(), notification_cq->cq(), this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ServerInterface::GenericAsyncRequest::GenericAsyncRequest( |
|
|
|
ServerInterface::GenericAsyncRequest::GenericAsyncRequest( |
|
|
@ -667,9 +672,10 @@ ServerInterface::GenericAsyncRequest::GenericAsyncRequest( |
|
|
|
grpc_call_details_init(&call_details_); |
|
|
|
grpc_call_details_init(&call_details_); |
|
|
|
GPR_ASSERT(notification_cq); |
|
|
|
GPR_ASSERT(notification_cq); |
|
|
|
GPR_ASSERT(call_cq); |
|
|
|
GPR_ASSERT(call_cq); |
|
|
|
grpc_server_request_call(server->server(), &call_, &call_details_, |
|
|
|
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( |
|
|
|
context->client_metadata_.arr(), call_cq->cq(), |
|
|
|
server->server(), &call_, &call_details_, |
|
|
|
notification_cq->cq(), this); |
|
|
|
context->client_metadata_.arr(), call_cq->cq(), |
|
|
|
|
|
|
|
notification_cq->cq(), this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, |
|
|
|
bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, |
|
|
|