server_cc.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2015 gRPC authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <limits.h>
19 #include <string.h>
20 
21 #include <algorithm>
22 #include <atomic>
23 #include <cstdlib>
24 #include <memory>
25 #include <new>
26 #include <sstream>
27 #include <string>
28 #include <type_traits>
29 #include <utility>
30 #include <vector>
31 
32 #include "absl/memory/memory.h"
33 
34 #include <grpc/byte_buffer.h>
35 #include <grpc/grpc.h>
38 #include <grpc/slice.h>
39 #include <grpc/support/log.h>
40 #include <grpc/support/sync.h>
41 #include <grpc/support/time.h>
42 #include <grpcpp/channel.h>
46 #include <grpcpp/impl/call.h>
56 #include <grpcpp/impl/rpc_method.h>
61 #include <grpcpp/server.h>
62 #include <grpcpp/server_context.h>
65 #include <grpcpp/support/config.h>
69 #include <grpcpp/support/slice.h>
70 #include <grpcpp/support/status.h>
71 
85 
86 namespace grpc {
87 namespace {
88 
89 // The default value for maximum number of threads that can be created in the
90 // sync server. This value of INT_MAX is chosen to match the default behavior if
91 // no ResourceQuota is set. To modify the max number of threads in a sync
92 // server, pass a custom ResourceQuota object (with the desired number of
93 // max-threads set) to the server builder.
94 #define DEFAULT_MAX_SYNC_SERVER_THREADS INT_MAX
95 
96 // Give a useful status error message if the resource is exhausted specifically
97 // because the server threadpool is full.
98 const char* kServerThreadpoolExhausted = "Server Threadpool Exhausted";
99 
100 // Although we might like to give a useful status error message on unimplemented
101 // RPCs, it's not always possible since that also would need to be added across
102 // languages and isn't actually required by the spec.
103 const char* kUnknownRpcMethod = "";
104 
105 class DefaultGlobalCallbacks final : public Server::GlobalCallbacks {
106  public:
107  ~DefaultGlobalCallbacks() override {}
108  void PreSynchronousRequest(ServerContext* /*context*/) override {}
109  void PostSynchronousRequest(ServerContext* /*context*/) override {}
110 };
111 
112 std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr;
113 gpr_once g_once_init_callbacks = GPR_ONCE_INIT;
114 
115 void InitGlobalCallbacks() {
116  if (!g_callbacks) {
117  g_callbacks.reset(new DefaultGlobalCallbacks());
118  }
119 }
120 
121 class ShutdownTag : public internal::CompletionQueueTag {
122  public:
123  bool FinalizeResult(void** /*tag*/, bool* /*status*/) override {
124  return false;
125  }
126 };
127 
128 class PhonyTag : public internal::CompletionQueueTag {
129  public:
130  bool FinalizeResult(void** /*tag*/, bool* /*status*/) override {
131  return true;
132  }
133 };
134 
135 class UnimplementedAsyncRequestContext {
136  protected:
137  UnimplementedAsyncRequestContext() : generic_stream_(&server_context_) {}
138 
139  GenericServerContext server_context_;
140  GenericServerAsyncReaderWriter generic_stream_;
141 };
142 
143 } // namespace
144 
148  ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize)
149  : server_(server),
150  context_(context),
151  stream_(stream),
152  call_cq_(call_cq),
153  notification_cq_(notification_cq),
154  tag_(tag),
155  delete_on_finalize_(delete_on_finalize),
156  call_(nullptr),
157  done_intercepting_(false) {
158  /* Set up interception state partially for the receive ops. call_wrapper_ is
159  * not filled at this point, but it will be filled before the interceptors are
160  * run. */
163  call_cq_->RegisterAvalanching(); // This op will trigger more ops
164 }
165 
167  call_cq_->CompleteAvalanching();
168 }
169 
171  bool* status) {
172  if (done_intercepting_) {
173  *tag = tag_;
174  if (delete_on_finalize_) {
175  delete this;
176  }
177  return true;
178  }
179  context_->set_call(call_);
180  context_->cq_ = call_cq_;
181  if (call_wrapper_.call() == nullptr) {
182  // Fill it since it is empty.
183  call_wrapper_ = internal::Call(
184  call_, server_, call_cq_, server_->max_receive_message_size(), nullptr);
185  }
186 
187  // just the pointers inside call are copied here
188  stream_->BindCall(&call_wrapper_);
189 
190  if (*status && call_ && call_wrapper_.server_rpc_info()) {
191  done_intercepting_ = true;
192  // Set interception point for RECV INITIAL METADATA
193  interceptor_methods_.AddInterceptionHookPoint(
195  interceptor_methods_.SetRecvInitialMetadata(&context_->client_metadata_);
196  if (interceptor_methods_.RunInterceptors(
197  [this]() { ContinueFinalizeResultAfterInterception(); })) {
198  // There are no interceptors to run. Continue
199  } else {
200  // There were interceptors to be run, so
201  // ContinueFinalizeResultAfterInterception will be run when interceptors
202  // are done.
203  return false;
204  }
205  }
206  if (*status && call_) {
207  context_->BeginCompletionOp(&call_wrapper_, nullptr, nullptr);
208  }
209  *tag = tag_;
210  if (delete_on_finalize_) {
211  delete this;
212  }
213  return true;
214 }
215 
218  context_->BeginCompletionOp(&call_wrapper_, nullptr, nullptr);
219  // Queue a tag which will be returned immediately
221  grpc_cq_begin_op(notification_cq_->cq(), this);
223  notification_cq_->cq(), this, GRPC_ERROR_NONE,
224  [](void* /*arg*/, grpc_cq_completion* completion) { delete completion; },
225  nullptr, new grpc_cq_completion());
226 }
227 
231  ServerCompletionQueue* notification_cq, void* tag, const char* name,
233  : BaseAsyncRequest(server, context, stream, call_cq, notification_cq, tag,
234  true),
235  name_(name),
236  type_(type) {}
237 
239  void* registered_method, grpc_byte_buffer** payload,
240  ServerCompletionQueue* notification_cq) {
241  // The following call_start_batch is internally-generated so no need for an
242  // explanatory log on failure.
244  server_->server(), registered_method, &call_,
245  &context_->deadline_, context_->client_metadata_.arr(),
246  payload, call_cq_->cq(), notification_cq->cq(),
247  this) == GRPC_CALL_OK);
248 }
249 
253  ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize)
254  : BaseAsyncRequest(server, context, stream, call_cq, notification_cq, tag,
255  delete_on_finalize) {
257  GPR_ASSERT(notification_cq);
258  GPR_ASSERT(call_cq);
259  // The following call_start_batch is internally-generated so no need for an
260  // explanatory log on failure.
262  context->client_metadata_.arr(),
263  call_cq->cq(), notification_cq->cq(),
264  this) == GRPC_CALL_OK);
265 }
266 
268  bool* status) {
269  // If we are done intercepting, there is nothing more for us to do
270  if (done_intercepting_) {
272  }
273  // TODO(yangg) remove the copy here.
274  if (*status) {
275  static_cast<GenericServerContext*>(context_)->method_ =
276  StringFromCopiedSlice(call_details_.method);
277  static_cast<GenericServerContext*>(context_)->host_ =
278  StringFromCopiedSlice(call_details_.host);
279  context_->deadline_ = call_details_.deadline;
280  }
281  grpc_slice_unref(call_details_.method);
282  grpc_slice_unref(call_details_.host);
283  call_wrapper_ = internal::Call(
284  call_, server_, call_cq_, server_->max_receive_message_size(),
285  context_->set_server_rpc_info(
286  static_cast<GenericServerContext*>(context_)->method_.c_str(),
288  *server_->interceptor_creators()));
290 }
291 
292 namespace {
293 class ShutdownCallback : public grpc_completion_queue_functor {
294  public:
295  ShutdownCallback() {
296  functor_run = &ShutdownCallback::Run;
297  // Set inlineable to true since this callback is trivial and thus does not
298  // need to be run from the executor (triggering a thread hop). This should
299  // only be used by internal callbacks like this and not by user application
300  // code.
301  inlineable = true;
302  }
303  // TakeCQ takes ownership of the cq into the shutdown callback
304  // so that the shutdown callback will be responsible for destroying it
305  void TakeCQ(CompletionQueue* cq) { cq_ = cq; }
306 
307  // The Run function will get invoked by the completion queue library
308  // when the shutdown is actually complete
309  static void Run(grpc_completion_queue_functor* cb, int) {
310  auto* callback = static_cast<ShutdownCallback*>(cb);
311  delete callback->cq_;
312  delete callback;
313  }
314 
315  private:
316  CompletionQueue* cq_ = nullptr;
317 };
318 } // namespace
319 
325  : private grpc::UnimplementedAsyncRequestContext,
326  public GenericAsyncRequest {
327  public:
330  : GenericAsyncRequest(server, &server_context_, &generic_stream_, cq, cq,
331  nullptr, false) {}
332 
333  bool FinalizeResult(void** tag, bool* status) override;
334 
335  grpc::ServerContext* context() { return &server_context_; }
336  grpc::GenericServerAsyncReaderWriter* stream() { return &generic_stream_; }
337 };
338 
342  : public grpc::internal::CallOpSet<
343  grpc::internal::CallOpSendInitialMetadata,
344  grpc::internal::CallOpServerSendStatus> {
345  public:
347  ~UnimplementedAsyncResponse() override { delete request_; }
348 
349  bool FinalizeResult(void** tag, bool* status) override {
353  status)) {
354  delete this;
355  } else {
356  // The tag was swallowed due to interception. We will see it again.
357  }
358  return false;
359  }
360 
361  private:
363 };
364 
366  public:
370  CommonSetup(data);
371  data->deadline = &deadline_;
372  data->optional_payload = has_request_payload_ ? &request_payload_ : nullptr;
373  }
374 
378  CommonSetup(data);
379  call_details_ = new grpc_call_details;
380  grpc_call_details_init(call_details_);
381  data->details = call_details_;
382  }
383 
384  ~SyncRequest() override {
385  // The destructor should only cleanup those objects created in the
386  // constructor, since some paths may or may not actually go through the
387  // Run stage where other objects are allocated.
388  if (has_request_payload_ && request_payload_) {
389  grpc_byte_buffer_destroy(request_payload_);
390  }
391  if (call_details_ != nullptr) {
392  grpc_call_details_destroy(call_details_);
393  delete call_details_;
394  }
395  grpc_metadata_array_destroy(&request_metadata_);
396  server_->UnrefWithPossibleNotify();
397  }
398 
399  bool FinalizeResult(void** /*tag*/, bool* status) override {
400  if (!*status) {
401  delete this;
402  return false;
403  }
404  if (call_details_) {
405  deadline_ = call_details_->deadline;
406  }
407  return true;
408  }
409 
410  void Run(const std::shared_ptr<GlobalCallbacks>& global_callbacks,
411  bool resources) {
412  ctx_.Init(deadline_, &request_metadata_);
413  wrapped_call_.Init(
414  call_, server_, &cq_, server_->max_receive_message_size(),
415  ctx_->ctx.set_server_rpc_info(method_->name(), method_->method_type(),
416  server_->interceptor_creators_));
417  ctx_->ctx.set_call(call_);
418  ctx_->ctx.cq_ = &cq_;
419  request_metadata_.count = 0;
420 
421  global_callbacks_ = global_callbacks;
422  resources_ = resources;
423 
424  interceptor_methods_.SetCall(&*wrapped_call_);
425  interceptor_methods_.SetReverse();
426  // Set interception point for RECV INITIAL METADATA
427  interceptor_methods_.AddInterceptionHookPoint(
429  interceptor_methods_.SetRecvInitialMetadata(&ctx_->ctx.client_metadata_);
430 
431  if (has_request_payload_) {
432  // Set interception point for RECV MESSAGE
433  auto* handler = resources_ ? method_->handler()
434  : server_->resource_exhausted_handler_.get();
435  deserialized_request_ = handler->Deserialize(call_, request_payload_,
436  &request_status_, nullptr);
437  if (!request_status_.ok()) {
438  gpr_log(GPR_DEBUG, "Failed to deserialize message.");
439  }
440  request_payload_ = nullptr;
441  interceptor_methods_.AddInterceptionHookPoint(
443  interceptor_methods_.SetRecvMessage(deserialized_request_, nullptr);
444  }
445 
446  if (interceptor_methods_.RunInterceptors(
447  [this]() { ContinueRunAfterInterception(); })) {
448  ContinueRunAfterInterception();
449  } else {
450  // There were interceptors to be run, so ContinueRunAfterInterception
451  // will be run when interceptors are done.
452  }
453  }
454 
456  ctx_->ctx.BeginCompletionOp(&*wrapped_call_, nullptr, nullptr);
457  global_callbacks_->PreSynchronousRequest(&ctx_->ctx);
458  auto* handler = resources_ ? method_->handler()
459  : server_->resource_exhausted_handler_.get();
461  &*wrapped_call_, &ctx_->ctx, deserialized_request_, request_status_,
462  nullptr, nullptr));
463  global_callbacks_->PostSynchronousRequest(&ctx_->ctx);
464 
465  cq_.Shutdown();
466 
467  grpc::internal::CompletionQueueTag* op_tag = ctx_->ctx.GetCompletionOpTag();
468  cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME));
469 
470  // Ensure the cq_ is shutdown
471  grpc::PhonyTag ignored_tag;
472  GPR_ASSERT(cq_.Pluck(&ignored_tag) == false);
473 
474  // Cleanup structures allocated during Run/ContinueRunAfterInterception
475  wrapped_call_.Destroy();
476  ctx_.Destroy();
477 
478  delete this;
479  }
480 
481  // For requests that must be only cleaned up but not actually Run
482  void Cleanup() {
483  cq_.Shutdown();
485  delete this;
486  }
487 
488  private:
490  : server_(server),
491  method_(method),
492  has_request_payload_(method->method_type() ==
493  grpc::internal::RpcMethod::NORMAL_RPC ||
494  method->method_type() ==
495  grpc::internal::RpcMethod::SERVER_STREAMING),
497 
498  template <class CallAllocation>
499  void CommonSetup(CallAllocation* data) {
500  server_->Ref();
501  grpc_metadata_array_init(&request_metadata_);
502  data->tag = static_cast<void*>(this);
503  data->call = &call_;
504  data->initial_metadata = &request_metadata_;
505  data->cq = cq_.cq();
506  }
507 
508  Server* const server_;
512  grpc_call_details* call_details_ = nullptr;
515  grpc_byte_buffer* request_payload_ = nullptr;
518  std::shared_ptr<GlobalCallbacks> global_callbacks_;
520  void* deserialized_request_ = nullptr;
522 
523  // ServerContextWrapper allows ManualConstructor while using a private
524  // contructor of ServerContext via this friend class.
527 
529  : ctx(deadline, arr) {}
530  };
531 
534 };
535 
536 template <class ServerContextType>
537 class Server::CallbackRequest final
539  public:
540  static_assert(
542  "ServerContextType must be derived from CallbackServerContext");
543 
544  // For codegen services, the value of method represents the defined
545  // characteristics of the method being requested. For generic services, method
546  // is nullptr since these services don't have pre-defined methods.
550  : server_(server),
551  method_(method),
552  has_request_payload_(method->method_type() ==
553  grpc::internal::RpcMethod::NORMAL_RPC ||
554  method->method_type() ==
555  grpc::internal::RpcMethod::SERVER_STREAMING),
556  cq_(cq),
557  tag_(this),
558  ctx_(server_->context_allocator() != nullptr
559  ? server_->context_allocator()->NewCallbackServerContext()
560  : nullptr) {
561  CommonSetup(server, data);
562  data->deadline = &deadline_;
563  data->optional_payload = has_request_payload_ ? &request_payload_ : nullptr;
564  }
565 
566  // For generic services, method is nullptr since these services don't have
567  // pre-defined methods.
570  : server_(server),
571  method_(nullptr),
572  has_request_payload_(false),
573  call_details_(new grpc_call_details),
574  cq_(cq),
575  tag_(this),
576  ctx_(server_->context_allocator() != nullptr
577  ? server_->context_allocator()
578  ->NewGenericCallbackServerContext()
579  : nullptr) {
580  CommonSetup(server, data);
581  grpc_call_details_init(call_details_);
582  data->details = call_details_;
583  }
584 
585  ~CallbackRequest() override {
586  delete call_details_;
587  grpc_metadata_array_destroy(&request_metadata_);
588  if (has_request_payload_ && request_payload_) {
589  grpc_byte_buffer_destroy(request_payload_);
590  }
591  if (ctx_alloc_by_default_ || server_->context_allocator() == nullptr) {
592  default_ctx_.Destroy();
593  }
594  server_->UnrefWithPossibleNotify();
595  }
596 
597  // Needs specialization to account for different processing of metadata
598  // in generic API
599  bool FinalizeResult(void** tag, bool* status) override;
600 
601  private:
602  // method_name needs to be specialized between named method and generic
603  const char* method_name() const;
604 
606  public:
608  : req_(req) {
609  functor_run = &CallbackCallTag::StaticRun;
610  // Set inlineable to true since this callback is internally-controlled
611  // without taking any locks, and thus does not need to be run from the
612  // executor (which triggers a thread hop). This should only be used by
613  // internal callbacks like this and not by user application code. The work
614  // here is actually non-trivial, but there is no chance of having user
615  // locks conflict with each other so it's ok to run inlined.
616  inlineable = true;
617  }
618 
619  // force_run can not be performed on a tag if operations using this tag
620  // have been sent to PerformOpsOnCall. It is intended for error conditions
621  // that are detected before the operations are internally processed.
622  void force_run(bool ok) { Run(ok); }
623 
624  private:
627 
629  static_cast<CallbackCallTag*>(cb)->Run(static_cast<bool>(ok));
630  }
631  void Run(bool ok) {
632  void* ignored = req_;
633  bool new_ok = ok;
634  GPR_ASSERT(!req_->FinalizeResult(&ignored, &new_ok));
635  GPR_ASSERT(ignored == req_);
636 
637  if (!ok) {
638  // The call has been shutdown.
639  // Delete its contents to free up the request.
640  delete req_;
641  return;
642  }
643 
644  // Bind the call, deadline, and metadata from what we got
645  req_->ctx_->set_call(req_->call_);
646  req_->ctx_->cq_ = req_->cq_;
647  req_->ctx_->BindDeadlineAndMetadata(req_->deadline_,
648  &req_->request_metadata_);
649  req_->request_metadata_.count = 0;
650 
651  // Create a C++ Call to control the underlying core call
652  call_ =
653  new (grpc_call_arena_alloc(req_->call_, sizeof(grpc::internal::Call)))
655  req_->call_, req_->server_, req_->cq_,
656  req_->server_->max_receive_message_size(),
657  req_->ctx_->set_server_rpc_info(
658  req_->method_name(),
659  (req_->method_ != nullptr)
660  ? req_->method_->method_type()
662  req_->server_->interceptor_creators_));
663 
664  req_->interceptor_methods_.SetCall(call_);
665  req_->interceptor_methods_.SetReverse();
666  // Set interception point for RECV INITIAL METADATA
667  req_->interceptor_methods_.AddInterceptionHookPoint(
669  POST_RECV_INITIAL_METADATA);
670  req_->interceptor_methods_.SetRecvInitialMetadata(
671  &req_->ctx_->client_metadata_);
672 
673  if (req_->has_request_payload_) {
674  // Set interception point for RECV MESSAGE
675  req_->request_ = req_->method_->handler()->Deserialize(
676  req_->call_, req_->request_payload_, &req_->request_status_,
677  &req_->handler_data_);
678  if (!(req_->request_status_.ok())) {
679  gpr_log(GPR_DEBUG, "Failed to deserialize message.");
680  }
681  req_->request_payload_ = nullptr;
682  req_->interceptor_methods_.AddInterceptionHookPoint(
684  req_->interceptor_methods_.SetRecvMessage(req_->request_, nullptr);
685  }
686 
687  if (req_->interceptor_methods_.RunInterceptors(
688  [this] { ContinueRunAfterInterception(); })) {
689  ContinueRunAfterInterception();
690  } else {
691  // There were interceptors to be run, so ContinueRunAfterInterception
692  // will be run when interceptors are done.
693  }
694  }
696  auto* handler = (req_->method_ != nullptr)
697  ? req_->method_->handler()
698  : req_->server_->generic_handler_.get();
700  call_, req_->ctx_, req_->request_, req_->request_status_,
701  req_->handler_data_, [this] { delete req_; }));
702  }
703  };
704 
705  template <class CallAllocation>
706  void CommonSetup(Server* server, CallAllocation* data) {
707  server->Ref();
708  grpc_metadata_array_init(&request_metadata_);
709  data->tag = static_cast<void*>(&tag_);
710  data->call = &call_;
711  data->initial_metadata = &request_metadata_;
712  if (ctx_ == nullptr) {
713  default_ctx_.Init();
714  ctx_ = &*default_ctx_;
715  ctx_alloc_by_default_ = true;
716  }
717  ctx_->set_context_allocator(server->context_allocator());
718  data->cq = cq_->cq();
719  }
720 
721  Server* const server_;
724  grpc_byte_buffer* request_payload_ = nullptr;
725  void* request_ = nullptr;
726  void* handler_data_ = nullptr;
728  grpc_call_details* const call_details_ = nullptr;
733  bool ctx_alloc_by_default_ = false;
735  ServerContextType* ctx_ = nullptr;
738 };
739 
740 template <>
742  void** /*tag*/, bool* /*status*/) {
743  return false;
744 }
745 
746 template <>
748  grpc::GenericCallbackServerContext>::FinalizeResult(void** /*tag*/,
749  bool* status) {
750  if (*status) {
751  deadline_ = call_details_->deadline;
752  // TODO(yangg) remove the copy here
753  ctx_->method_ = grpc::StringFromCopiedSlice(call_details_->method);
754  ctx_->host_ = grpc::StringFromCopiedSlice(call_details_->host);
755  }
756  grpc_slice_unref(call_details_->method);
757  grpc_slice_unref(call_details_->host);
758  return false;
759 }
760 
761 template <>
763  const {
764  return method_->name();
765 }
766 
767 template <>
768 const char* Server::CallbackRequest<
770  return ctx_->method().c_str();
771 }
772 
773 // Implementation of ThreadManager. Each instance of SyncRequestThreadManager
774 // manages a pool of threads that poll for incoming Sync RPCs and call the
775 // appropriate RPC handlers
777  public:
779  std::shared_ptr<GlobalCallbacks> global_callbacks,
780  grpc_resource_quota* rq, int min_pollers,
781  int max_pollers, int cq_timeout_msec)
782  : ThreadManager("SyncServer", rq, min_pollers, max_pollers),
783  server_(server),
784  server_cq_(server_cq),
785  cq_timeout_msec_(cq_timeout_msec),
786  global_callbacks_(std::move(global_callbacks)) {}
787 
788  WorkStatus PollForWork(void** tag, bool* ok) override {
789  *tag = nullptr;
790  // TODO(ctiller): workaround for GPR_TIMESPAN based deadlines not working
791  // right now
792  gpr_timespec deadline =
794  gpr_time_from_millis(cq_timeout_msec_, GPR_TIMESPAN));
795 
796  switch (server_cq_->AsyncNext(tag, ok, deadline)) {
798  return TIMEOUT;
800  return SHUTDOWN;
802  return WORK_FOUND;
803  }
804 
806  }
807 
808  void DoWork(void* tag, bool ok, bool resources) override {
809  (void)ok;
810  SyncRequest* sync_req = static_cast<SyncRequest*>(tag);
811 
812  // Under the AllocatingRequestMatcher model we will never see an invalid tag
813  // here.
814  GPR_DEBUG_ASSERT(sync_req != nullptr);
816 
817  GPR_TIMER_SCOPE("sync_req->Run()", 0);
818  sync_req->Run(global_callbacks_, resources);
819  }
820 
823  ->SetRegisteredMethodAllocator(server_cq_->cq(), tag, [this, method] {
824  grpc_core::Server::RegisteredCallAllocation result;
825  new SyncRequest(server_, method, &result);
826  return result;
827  });
828  has_sync_method_ = true;
829  }
830 
832  if (has_sync_method_) {
833  unknown_method_ = absl::make_unique<grpc::internal::RpcServiceMethod>(
835  new grpc::internal::UnknownMethodHandler(kUnknownRpcMethod));
837  ->SetBatchMethodAllocator(server_cq_->cq(), [this] {
838  grpc_core::Server::BatchCallAllocation result;
839  new SyncRequest(server_, unknown_method_.get(), &result);
840  return result;
841  });
842  }
843  }
844 
845  void Shutdown() override {
847  server_cq_->Shutdown();
848  }
849 
850  void Wait() override {
852  // Drain any pending items from the queue
853  void* tag;
854  bool ok;
855  while (server_cq_->Next(&tag, &ok)) {
856  // This problem can arise if the server CQ gets a request queued to it
857  // before it gets shutdown but then pulls it after shutdown.
858  static_cast<SyncRequest*>(tag)->Cleanup();
859  }
860  }
861 
862  void Start() {
863  if (has_sync_method_) {
864  Initialize(); // ThreadManager's Initialize()
865  }
866  }
867 
868  private:
872  bool has_sync_method_ = false;
873  std::unique_ptr<grpc::internal::RpcServiceMethod> unknown_method_;
874  std::shared_ptr<Server::GlobalCallbacks> global_callbacks_;
875 };
876 
880  std::shared_ptr<std::vector<std::unique_ptr<grpc::ServerCompletionQueue>>>
881  sync_server_cqs,
882  int min_pollers, int max_pollers, int sync_cq_timeout_msec,
883  std::vector<std::shared_ptr<grpc::internal::ExternalConnectionAcceptorImpl>>
884  acceptors,
885  grpc_server_config_fetcher* server_config_fetcher,
886  grpc_resource_quota* server_rq,
887  std::vector<
888  std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>
890  : acceptors_(std::move(acceptors)),
891  interceptor_creators_(std::move(interceptor_creators)),
892  max_receive_message_size_(INT_MIN),
893  sync_server_cqs_(std::move(sync_server_cqs)),
894  started_(false),
895  shutdown_(false),
896  shutdown_notified_(false),
897  server_(nullptr),
898  server_initializer_(new ServerInitializer(this)),
899  health_check_service_disabled_(false) {
901  gpr_once_init(&grpc::g_once_init_callbacks, grpc::InitGlobalCallbacks);
902  global_callbacks_ = grpc::g_callbacks;
903  global_callbacks_->UpdateArguments(args);
904 
905  if (sync_server_cqs_ != nullptr) {
906  bool default_rq_created = false;
907  if (server_rq == nullptr) {
908  server_rq = grpc_resource_quota_create("SyncServer-default-rq");
911  default_rq_created = true;
912  }
913 
914  for (const auto& it : *sync_server_cqs_) {
915  sync_req_mgrs_.emplace_back(new SyncRequestThreadManager(
916  this, it.get(), global_callbacks_, server_rq, min_pollers,
917  max_pollers, sync_cq_timeout_msec));
918  }
919 
920  if (default_rq_created) {
921  grpc_resource_quota_unref(server_rq);
922  }
923  }
924 
925  for (auto& acceptor : acceptors_) {
926  acceptor->SetToChannelArgs(args);
927  }
928 
929  grpc_channel_args channel_args;
930  args->SetChannelArgs(&channel_args);
931 
932  for (size_t i = 0; i < channel_args.num_args; i++) {
933  if (0 == strcmp(channel_args.args[i].key,
935  if (channel_args.args[i].value.pointer.p == nullptr) {
936  health_check_service_disabled_ = true;
937  } else {
938  health_check_service_.reset(
939  static_cast<grpc::HealthCheckServiceInterface*>(
940  channel_args.args[i].value.pointer.p));
941  }
942  }
943  if (0 ==
944  strcmp(channel_args.args[i].key, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH)) {
945  max_receive_message_size_ = channel_args.args[i].value.integer;
946  }
947  }
948  server_ = grpc_server_create(&channel_args, nullptr);
949  grpc_server_set_config_fetcher(server_, server_config_fetcher);
950 }
951 
952 Server::~Server() {
953  {
955  if (started_ && !shutdown_) {
956  lock.Release();
957  Shutdown();
958  } else if (!started_) {
959  // Shutdown the completion queues
960  for (const auto& value : sync_req_mgrs_) {
961  value->Shutdown();
962  }
963  CompletionQueue* callback_cq =
964  callback_cq_.load(std::memory_order_relaxed);
965  if (callback_cq != nullptr) {
967  // gRPC-core provides the backing needed for the preferred CQ type
968  callback_cq->Shutdown();
969  } else {
970  CompletionQueue::ReleaseCallbackAlternativeCQ(callback_cq);
971  }
972  callback_cq_.store(nullptr, std::memory_order_release);
973  }
974  }
975  }
976  // Destroy health check service before we destroy the C server so that
977  // it does not call grpc_server_request_registered_call() after the C
978  // server has been destroyed.
979  health_check_service_.reset();
981 }
982 
983 void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
984  GPR_ASSERT(!grpc::g_callbacks);
986  grpc::g_callbacks.reset(callbacks);
987 }
988 
989 grpc_server* Server::c_server() { return server_; }
990 
991 std::shared_ptr<grpc::Channel> Server::InProcessChannel(
992  const grpc::ChannelArguments& args) {
993  grpc_channel_args channel_args = args.c_channel_args();
995  "inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr),
996  std::vector<std::unique_ptr<
998 }
999 
1000 std::shared_ptr<grpc::Channel>
1001 Server::experimental_type::InProcessChannelWithInterceptors(
1003  std::vector<
1004  std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
1005  interceptor_creators) {
1006  grpc_channel_args channel_args = args.c_channel_args();
1008  "inproc",
1009  grpc_inproc_channel_create(server_->server_, &channel_args, nullptr),
1010  std::move(interceptor_creators));
1011 }
1012 
1015  switch (method->method_type()) {
1021  return GRPC_SRM_PAYLOAD_NONE;
1022  }
1024 }
1025 
1026 bool Server::RegisterService(const std::string* addr, grpc::Service* service) {
1027  bool has_async_methods = service->has_async_methods();
1028  if (has_async_methods) {
1029  GPR_ASSERT(service->server_ == nullptr &&
1030  "Can only register an asynchronous service against one server.");
1031  service->server_ = this;
1032  }
1033 
1034  const char* method_name = nullptr;
1035 
1036  for (const auto& method : service->methods_) {
1037  if (method == nullptr) { // Handled by generic service if any.
1038  continue;
1039  }
1040 
1041  void* method_registration_tag = grpc_server_register_method(
1042  server_, method->name(), addr ? addr->c_str() : nullptr,
1043  PayloadHandlingForMethod(method.get()), 0);
1044  if (method_registration_tag == nullptr) {
1045  gpr_log(GPR_DEBUG, "Attempt to register %s multiple times",
1046  method->name());
1047  return false;
1048  }
1049 
1050  if (method->handler() == nullptr) { // Async method without handler
1051  method->set_server_tag(method_registration_tag);
1052  } else if (method->api_type() ==
1054  for (const auto& value : sync_req_mgrs_) {
1055  value->AddSyncMethod(method.get(), method_registration_tag);
1056  }
1057  } else {
1058  has_callback_methods_ = true;
1059  grpc::internal::RpcServiceMethod* method_value = method.get();
1060  grpc::CompletionQueue* cq = CallbackCQ();
1062  cq->cq(), method_registration_tag, [this, cq, method_value] {
1063  grpc_core::Server::RegisteredCallAllocation result;
1064  new CallbackRequest<grpc::CallbackServerContext>(this, method_value,
1065  cq, &result);
1066  return result;
1067  });
1068  }
1069 
1070  method_name = method->name();
1071  }
1072 
1073  // Parse service name.
1074  if (method_name != nullptr) {
1075  std::stringstream ss(method_name);
1076  std::string service_name;
1077  if (std::getline(ss, service_name, '/') &&
1078  std::getline(ss, service_name, '/')) {
1079  services_.push_back(service_name);
1080  }
1081  }
1082  return true;
1083 }
1084 
1085 void Server::RegisterAsyncGenericService(grpc::AsyncGenericService* service) {
1086  GPR_ASSERT(service->server_ == nullptr &&
1087  "Can only register an async generic service against one server.");
1088  service->server_ = this;
1089  has_async_generic_service_ = true;
1090 }
1091 
1092 void Server::RegisterCallbackGenericService(
1094  GPR_ASSERT(
1095  service->server_ == nullptr &&
1096  "Can only register a callback generic service against one server.");
1097  service->server_ = this;
1098  has_callback_generic_service_ = true;
1099  generic_handler_.reset(service->Handler());
1100 
1101  grpc::CompletionQueue* cq = CallbackCQ();
1103  cq] {
1104  grpc_core::Server::BatchCallAllocation result;
1105  new CallbackRequest<grpc::GenericCallbackServerContext>(this, cq, &result);
1106  return result;
1107  });
1108 }
1109 
1110 int Server::AddListeningPort(const std::string& addr,
1111  grpc::ServerCredentials* creds) {
1112  GPR_ASSERT(!started_);
1113  int port = creds->AddPortToServer(addr, server_);
1114  global_callbacks_->AddPort(this, addr, creds, port);
1115  return port;
1116 }
1117 
1118 void Server::Ref() {
1119  shutdown_refs_outstanding_.fetch_add(1, std::memory_order_relaxed);
1120 }
1121 
1122 void Server::UnrefWithPossibleNotify() {
1123  if (GPR_UNLIKELY(shutdown_refs_outstanding_.fetch_sub(
1124  1, std::memory_order_acq_rel) == 1)) {
1125  // No refs outstanding means that shutdown has been initiated and no more
1126  // callback requests are outstanding.
1129  shutdown_done_ = true;
1130  shutdown_done_cv_.Signal();
1131  }
1132 }
1133 
1134 void Server::UnrefAndWaitLocked() {
1135  if (GPR_UNLIKELY(shutdown_refs_outstanding_.fetch_sub(
1136  1, std::memory_order_acq_rel) == 1)) {
1137  shutdown_done_ = true;
1138  return; // no need to wait on CV since done condition already set
1139  }
1140  while (!shutdown_done_) {
1141  shutdown_done_cv_.Wait(&mu_);
1142  }
1143 }
1144 
1145 void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) {
1146  GPR_ASSERT(!started_);
1147  global_callbacks_->PreServerStart(this);
1148  started_ = true;
1149 
1150  // Only create default health check service when user did not provide an
1151  // explicit one.
1152  grpc::ServerCompletionQueue* health_check_cq = nullptr;
1154  default_health_check_service_impl = nullptr;
1155  if (health_check_service_ == nullptr && !health_check_service_disabled_ &&
1157  auto* default_hc_service = new grpc::DefaultHealthCheckService;
1158  health_check_service_.reset(default_hc_service);
1159  // We create a non-polling CQ to avoid impacting application
1160  // performance. This ensures that we don't introduce thread hops
1161  // for application requests that wind up on this CQ, which is polled
1162  // in its own thread.
1163  health_check_cq = new grpc::ServerCompletionQueue(
1164  GRPC_CQ_NEXT, GRPC_CQ_NON_POLLING, nullptr);
1165  grpc_server_register_completion_queue(server_, health_check_cq->cq(),
1166  nullptr);
1167  default_health_check_service_impl =
1168  default_hc_service->GetHealthCheckService(
1169  std::unique_ptr<grpc::ServerCompletionQueue>(health_check_cq));
1170  RegisterService(nullptr, default_health_check_service_impl);
1171  }
1172 
1173  for (auto& acceptor : acceptors_) {
1174  acceptor->GetCredentials()->AddPortToServer(acceptor->name(), server_);
1175  }
1176 
1177  // If this server uses callback methods, then create a callback generic
1178  // service to handle any unimplemented methods using the default reactor
1179  // creator
1180  if (has_callback_methods_ && !has_callback_generic_service_) {
1181  unimplemented_service_ = absl::make_unique<grpc::CallbackGenericService>();
1182  RegisterCallbackGenericService(unimplemented_service_.get());
1183  }
1184 
1185 #ifndef NDEBUG
1186  for (size_t i = 0; i < num_cqs; i++) {
1187  cq_list_.push_back(cqs[i]);
1188  }
1189 #endif
1190 
1191  // If we have a generic service, all unmatched method names go there.
1192  // Otherwise, we must provide at least one RPC request for an "unimplemented"
1193  // RPC, which covers any RPC for a method name that isn't matched. If we
1194  // have a sync service, let it be a sync unimplemented RPC, which must be
1195  // registered before server start (to initialize an AllocatingRequestMatcher).
1196  // If we have an AllocatingRequestMatcher, we can't also specify other
1197  // unimplemented RPCs via explicit async requests, so we won't do so. If we
1198  // only have async services, we can specify unimplemented RPCs on each async
1199  // CQ so that some user polling thread will move them along as long as some
1200  // progress is being made on any RPCs in the system.
1201  bool unknown_rpc_needed =
1202  !has_async_generic_service_ && !has_callback_generic_service_;
1203 
1204  if (unknown_rpc_needed && !sync_req_mgrs_.empty()) {
1205  sync_req_mgrs_[0]->AddUnknownSyncMethod();
1206  unknown_rpc_needed = false;
1207  }
1208 
1210 
1211  if (unknown_rpc_needed) {
1212  for (size_t i = 0; i < num_cqs; i++) {
1213  if (cqs[i]->IsFrequentlyPolled()) {
1214  new UnimplementedAsyncRequest(this, cqs[i]);
1215  }
1216  }
1217  if (health_check_cq != nullptr) {
1218  new UnimplementedAsyncRequest(this, health_check_cq);
1219  }
1220  unknown_rpc_needed = false;
1221  }
1222 
1223  // If this server has any support for synchronous methods (has any sync
1224  // server CQs), make sure that we have a ResourceExhausted handler
1225  // to deal with the case of thread exhaustion
1226  if (sync_server_cqs_ != nullptr && !sync_server_cqs_->empty()) {
1227  resource_exhausted_handler_ =
1228  absl::make_unique<grpc::internal::ResourceExhaustedHandler>(
1229  kServerThreadpoolExhausted);
1230  }
1231 
1232  for (const auto& value : sync_req_mgrs_) {
1233  value->Start();
1234  }
1235 
1236  if (default_health_check_service_impl != nullptr) {
1237  default_health_check_service_impl->StartServingThread();
1238  }
1239 
1240  for (auto& acceptor : acceptors_) {
1241  acceptor->Start();
1242  }
1243 }
1244 
1245 void Server::ShutdownInternal(gpr_timespec deadline) {
1247  if (shutdown_) {
1248  return;
1249  }
1250 
1251  shutdown_ = true;
1252 
1253  for (auto& acceptor : acceptors_) {
1254  acceptor->Shutdown();
1255  }
1256 
1258  grpc::CompletionQueue shutdown_cq;
1259  grpc::ShutdownTag shutdown_tag; // Phony shutdown tag
1260  grpc_server_shutdown_and_notify(server_, shutdown_cq.cq(), &shutdown_tag);
1261 
1262  shutdown_cq.Shutdown();
1263 
1264  void* tag;
1265  bool ok;
1267  shutdown_cq.AsyncNext(&tag, &ok, deadline);
1268 
1269  // If this timed out, it means we are done with the grace period for a clean
1270  // shutdown. We should force a shutdown now by cancelling all inflight calls
1273  }
1274  // Else in case of SHUTDOWN or GOT_EVENT, it means that the server has
1275  // successfully shutdown
1276 
1277  // Drop the shutdown ref and wait for all other refs to drop as well.
1278  UnrefAndWaitLocked();
1279 
1280  // Shutdown all ThreadManagers. This will try to gracefully stop all the
1281  // threads in the ThreadManagers (once they process any inflight requests)
1282  for (const auto& value : sync_req_mgrs_) {
1283  value->Shutdown(); // ThreadManager's Shutdown()
1284  }
1285 
1286  // Wait for threads in all ThreadManagers to terminate
1287  for (const auto& value : sync_req_mgrs_) {
1288  value->Wait();
1289  }
1290 
1291  // Shutdown the callback CQ. The CQ is owned by its own shutdown tag, so it
1292  // will delete itself at true shutdown.
1293  CompletionQueue* callback_cq = callback_cq_.load(std::memory_order_relaxed);
1294  if (callback_cq != nullptr) {
1296  // gRPC-core provides the backing needed for the preferred CQ type
1297  callback_cq->Shutdown();
1298  } else {
1299  CompletionQueue::ReleaseCallbackAlternativeCQ(callback_cq);
1300  }
1301  callback_cq_.store(nullptr, std::memory_order_release);
1302  }
1303 
1304  // Drain the shutdown queue (if the previous call to AsyncNext() timed out
1305  // and we didn't remove the tag from the queue yet)
1306  while (shutdown_cq.Next(&tag, &ok)) {
1307  // Nothing to be done here. Just ignore ok and tag values
1308  }
1309 
1310  shutdown_notified_ = true;
1311  shutdown_cv_.SignalAll();
1312 
1313 #ifndef NDEBUG
1314  // Unregister this server with the CQs passed into it by the user so that
1315  // those can be checked for properly-ordered shutdown.
1316  for (auto* cq : cq_list_) {
1317  cq->UnregisterServer(this);
1318  }
1319  cq_list_.clear();
1320 #endif
1321 }
1322 
1323 void Server::Wait() {
1325  while (started_ && !shutdown_notified_) {
1326  shutdown_cv_.Wait(&mu_);
1327  }
1328 }
1329 
1330 void Server::PerformOpsOnCall(grpc::internal::CallOpSetInterface* ops,
1332  ops->FillOps(call);
1333 }
1334 
1335 bool Server::UnimplementedAsyncRequest::FinalizeResult(void** tag,
1336  bool* status) {
1337  if (GenericAsyncRequest::FinalizeResult(tag, status)) {
1338  // We either had no interceptors run or we are done intercepting
1339  if (*status) {
1340  // Create a new request/response pair using the server and CQ values
1341  // stored in this object's base class.
1342  new UnimplementedAsyncRequest(server_, notification_cq_);
1343  new UnimplementedAsyncResponse(this);
1344  } else {
1345  delete this;
1346  }
1347  } else {
1348  // The tag was swallowed due to interception. We will see it again.
1349  }
1350  return false;
1351 }
1352 
1353 Server::UnimplementedAsyncResponse::UnimplementedAsyncResponse(
1355  : request_(request) {
1358  kUnknownRpcMethod, this);
1359  request_->stream()->call_.PerformOps(this);
1360 }
1361 
1363  return server_initializer_.get();
1364 }
1365 
1367  // TODO(vjpai): Consider using a single global CQ for the default CQ
1368  // if there is no explicit per-server CQ registered
1369  CompletionQueue* callback_cq = callback_cq_.load(std::memory_order_acquire);
1370  if (callback_cq != nullptr) {
1371  return callback_cq;
1372  }
1373  // The callback_cq_ wasn't already set, so grab a lock and set it up exactly
1374  // once for this server.
1376  callback_cq = callback_cq_.load(std::memory_order_relaxed);
1377  if (callback_cq != nullptr) {
1378  return callback_cq;
1379  }
1381  // gRPC-core provides the backing needed for the preferred CQ type
1382  auto* shutdown_callback = new grpc::ShutdownCallback;
1385  shutdown_callback});
1386 
1387  // Transfer ownership of the new cq to its own shutdown callback
1388  shutdown_callback->TakeCQ(callback_cq);
1389  } else {
1390  // Otherwise we need to use the alternative CQ variant
1392  }
1393 
1394  callback_cq_.store(callback_cq, std::memory_order_release);
1395  return callback_cq;
1396 }
1397 
1398 } // namespace grpc
grpc::Server::CallbackRequest::CallbackCallTag::force_run
void force_run(bool ok)
Definition: server_cc.cc:622
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Definition: slice_api.cc:32
grpc::CreateChannelInternal
std::shared_ptr< Channel > CreateChannelInternal(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
cq_
grpc_completion_queue * cq_
Definition: channel_connectivity.cc:210
grpc::ServerInterface::RegisteredAsyncRequest::RegisteredAsyncRequest
RegisteredAsyncRequest(ServerInterface *server, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag, const char *name, internal::RpcMethod::RpcType type)
Definition: server_cc.cc:228
GRPC_SRM_PAYLOAD_NONE
@ GRPC_SRM_PAYLOAD_NONE
Definition: grpc.h:398
grpc::Server::server_initializer_
std::unique_ptr< ServerInitializer > server_initializer_
Definition: include/grpcpp/server.h:316
grpc::status
auto status
Definition: cpp/client/credentials_test.cc:200
iomgr.h
grpc::Server::SyncRequestThreadManager::Start
void Start()
Definition: server_cc.cc:862
grpc::ServerCompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:436
grpc::CompletionQueue::SHUTDOWN
@ SHUTDOWN
The completion queue has been shutdown and fully-drained.
Definition: include/grpcpp/impl/codegen/completion_queue.h:125
grpc::Server::CallbackRequest::CallbackCallTag::StaticRun
static void StaticRun(grpc_completion_queue_functor *cb, int ok)
Definition: server_cc.cc:628
grpc_call_details_destroy
GRPCAPI void grpc_call_details_destroy(grpc_call_details *details)
Definition: call_details.cc:36
thread_manager.h
regen-readme.it
it
Definition: regen-readme.py:15
grpc_call_details_init
GRPCAPI void grpc_call_details_init(grpc_call_details *details)
Definition: call_details.cc:30
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
create_channel_internal.h
grpc::AsyncGenericService
Definition: grpcpp/impl/codegen/async_generic_service.h:70
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
log.h
grpc::CompletionQueue::RegisterAvalanching
void RegisterAvalanching()
Definition: include/grpcpp/impl/codegen/completion_queue.h:386
grpc::GenericServerContext::method_
std::string method_
Definition: grpcpp/impl/codegen/async_generic_service.h:49
grpc_call_arena_alloc
GRPCAPI void * grpc_call_arena_alloc(grpc_call *call, size_t size)
Definition: call.cc:1749
server_initializer.h
interceptor.h
ctx
Definition: benchmark-async.c:30
grpc::internal::RpcServiceMethod::ApiType::SYNC
@ SYNC
grpc::Server::SyncRequest::Run
void Run(const std::shared_ptr< GlobalCallbacks > &global_callbacks, bool resources)
Definition: server_cc.cc:410
grpc::Server::UnimplementedAsyncRequest
Definition: server_cc.cc:324
call_
grpc_call * call_
Definition: rls.cc:669
deadline_
Timestamp deadline_
Definition: channel_connectivity.cc:163
grpc::Server::CallbackRequest::cq_
grpc::CompletionQueue *const cq_
Definition: server_cc.cc:732
GRPC_CQ_NEXT
@ GRPC_CQ_NEXT
Definition: grpc_types.h:760
grpc_arg::value
union grpc_arg::grpc_arg_value value
grpc_completion_queue_create_for_pluck
GRPCAPI grpc_completion_queue * grpc_completion_queue_create_for_pluck(void *reserved)
Definition: completion_queue_factory.cc:69
GPR_DEBUG_ASSERT
#define GPR_DEBUG_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:103
grpc_core::Server::BatchCallAllocation
Definition: src/core/lib/surface/server.h:86
grpc::Server::SyncRequestThreadManager::SyncRequestThreadManager
SyncRequestThreadManager(Server *server, grpc::CompletionQueue *server_cq, std::shared_ptr< GlobalCallbacks > global_callbacks, grpc_resource_quota *rq, int min_pollers, int max_pollers, int cq_timeout_msec)
Definition: server_cc.cc:778
grpc::Server::UnimplementedAsyncRequest::UnimplementedAsyncRequest
UnimplementedAsyncRequest(ServerInterface *server, grpc::ServerCompletionQueue *cq)
Definition: server_cc.cc:328
grpc_arg::grpc_arg_value::pointer
struct grpc_arg::grpc_arg_value::grpc_arg_pointer pointer
timers.h
grpc
Definition: grpcpp/alarm.h:33
gpr_once
pthread_once_t gpr_once
Definition: impl/codegen/sync_posix.h:50
grpc_resource_quota
struct grpc_resource_quota grpc_resource_quota
Definition: grpc_types.h:729
grpc_server_config_fetcher
Definition: src/core/lib/surface/server.h:497
grpc::CompletionQueue::GOT_EVENT
@ GOT_EVENT
Definition: include/grpcpp/impl/codegen/completion_queue.h:126
stream_
std::unique_ptr< grpc::ClientReaderInterface< OrcaLoadReport > > stream_
Definition: orca_service_end2end_test.cc:89
req_
EchoRequest req_
Definition: client_interceptors_end2end_test.cc:290
interceptor_common.h
slice.h
unimplemented_service_
grpc::testing::UnimplementedEchoService::Service unimplemented_service_
Definition: hybrid_end2end_test.cc:436
grpc::Server::Server
Server(ChannelArguments *args, std::shared_ptr< std::vector< std::unique_ptr< ServerCompletionQueue >>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, std::vector< std::shared_ptr< internal::ExternalConnectionAcceptorImpl >> acceptors, grpc_server_config_fetcher *server_config_fetcher=nullptr, grpc_resource_quota *server_rq=nullptr, std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface >> interceptor_creators=std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface >>())
false
#define false
Definition: setup_once.h:323
DEFAULT_MAX_SYNC_SERVER_THREADS
#define DEFAULT_MAX_SYNC_SERVER_THREADS
Definition: server_cc.cc:94
grpc.framework.interfaces.base.utilities.completion
def completion(terminal_metadata, code, message)
Definition: framework/interfaces/base/utilities.py:45
GPR_TIMER_SCOPE
#define GPR_TIMER_SCOPE(tag, important)
Definition: src/core/lib/profiling/timers.h:43
GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
Definition: grpc_types.h:153
grpc::experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA
@ POST_RECV_INITIAL_METADATA
The following two are for all clients and servers.
grpc::experimental::InterceptionHookPoints::POST_RECV_MESSAGE
@ POST_RECV_MESSAGE
grpc::internal::GrpcLibraryInitializer::summon
int summon()
Definition: grpcpp/impl/grpc_library.h:54
grpc_metadata_array
Definition: grpc_types.h:579
grpc_call_details
Definition: grpc_types.h:585
callbacks
static unsigned int callbacks
Definition: benchmark-async-pummel.c:31
grpc::g_gli_initializer
static grpc::internal::GrpcLibraryInitializer g_gli_initializer
Definition: channel_cc.cc:52
grpc::ThreadManager::Shutdown
virtual void Shutdown()
Definition: thread_manager.cc:83
grpc::Server::CallbackRequest::tag_
CallbackCallTag tag_
Definition: server_cc.cc:734
string.h
grpc::ServerInterface::BaseAsyncRequest::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
Definition: server_cc.cc:170
benchmark.request
request
Definition: benchmark.py:77
grpc::internal::CallOpSetInterface
Definition: call_op_set_interface.h:36
grpc::Server::UnimplementedAsyncResponse::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
Definition: server_cc.cc:349
grpc::experimental::ClientInterceptorFactoryInterface
Definition: impl/codegen/client_interceptor.h:48
grpc::Server::CallbackRequest::interceptor_methods_
grpc::internal::InterceptorBatchMethodsImpl interceptor_methods_
Definition: server_cc.cc:737
grpc::Server::SyncRequest::global_callbacks_
std::shared_ptr< GlobalCallbacks > global_callbacks_
Definition: server_cc.cc:518
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
type_
std::string type_
Definition: client_channel_stress_test.cc:212
slice.h
completion_queue.h
external_connection_acceptor_impl.h
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:37
grpc::Server::mu_
internal::Mutex mu_
Definition: include/grpcpp/server.h:295
grpc_server_create
GRPCAPI grpc_server * grpc_server_create(const grpc_channel_args *args, void *reserved)
Definition: src/core/lib/surface/server.cc:1456
health_check_service_interface.h
grpc::Server::SyncRequest::Cleanup
void Cleanup()
Definition: server_cc.cc:482
grpc_cq_completion
Definition: src/core/lib/surface/completion_queue.h:43
grpc::CompletionQueue::NextStatus
NextStatus
Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
Definition: include/grpcpp/impl/codegen/completion_queue.h:124
rpc_service_method.h
grpc::GenericServerContext
Definition: grpcpp/impl/codegen/async_generic_service.h:41
GRPC_CALL_OK
@ GRPC_CALL_OK
Definition: grpc_types.h:466
status
absl::Status status
Definition: rls.cc:251
grpc_server_register_completion_queue
GRPCAPI void grpc_server_register_completion_queue(grpc_server *server, grpc_completion_queue *cq, void *reserved)
Definition: src/core/lib/surface/server.cc:1466
gpr_inf_future
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
Definition: src/core/lib/gpr/time.cc:55
grpc::Server::SyncRequest::~SyncRequest
~SyncRequest() override
Definition: server_cc.cc:384
grpc::ServerAsyncReaderWriter
Definition: grpcpp/impl/codegen/async_stream.h:1010
grpc_resource_quota_create
GRPCAPI grpc_resource_quota * grpc_resource_quota_create(const char *trace_name)
Definition: api.cc:66
grpc::internal::ErrorMethodHandler
Definition: include/grpcpp/impl/codegen/byte_buffer.h:49
grpc_server_request_registered_call
GRPCAPI grpc_call_error grpc_server_request_registered_call(grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new)
Definition: src/core/lib/surface/server.cc:1546
GPR_ONCE_INIT
#define GPR_ONCE_INIT
Definition: impl/codegen/sync_posix.h:52
grpc_cq_end_op
void grpc_cq_end_op(grpc_completion_queue *cq, void *tag, grpc_error_handle error, void(*done)(void *done_arg, grpc_cq_completion *storage), void *done_arg, grpc_cq_completion *storage, bool internal)
Definition: completion_queue.cc:894
setup.name
name
Definition: setup.py:542
rpc_method.h
async_generic_service.h
grpc::Server::CallbackRequest::request_metadata_
grpc_metadata_array request_metadata_
Definition: server_cc.cc:731
time.h
ctx_
ClientContext ctx_
Definition: client_interceptors_end2end_test.cc:289
method_type
zend_class_entry * method_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/message.c:2232
grpc_core::Server::SetBatchMethodAllocator
void SetBatchMethodAllocator(grpc_completion_queue *cq, std::function< BatchCallAllocation()> allocator)
Definition: src/core/lib/surface/server.cc:651
grpc::Server::CallbackRequest::CallbackCallTag
Definition: server_cc.cc:605
name_
const std::string name_
Definition: priority.cc:233
env.new
def new
Definition: env.py:51
grpc::Server::CallbackRequest::CallbackRequest
CallbackRequest(Server *server, grpc::internal::RpcServiceMethod *method, grpc::CompletionQueue *cq, grpc_core::Server::RegisteredCallAllocation *data)
Definition: server_cc.cc:547
inproc_transport.h
grpc::Server::CallbackRequest::method_
grpc::internal::RpcServiceMethod *const method_
Definition: server_cc.cc:722
grpc::Server::SyncRequest::CommonSetup
void CommonSetup(CallAllocation *data)
Definition: server_cc.cc:499
grpc_channel_args
Definition: grpc_types.h:132
grpc::internal::MutexLock
Definition: include/grpcpp/impl/codegen/sync.h:86
grpc_server_register_method_payload_handling
grpc_server_register_method_payload_handling
Definition: grpc.h:396
true
#define true
Definition: setup_once.h:324
metadata_map.h
mu_
Mutex mu_
Definition: oob_backend_metric.cc:115
server_
Server *const server_
Definition: chttp2_server.cc:260
call
FilterStackCall * call
Definition: call.cc:750
grpc::Server::SyncRequest::method_
grpc::internal::RpcServiceMethod *const method_
Definition: server_cc.cc:509
grpc::CompletionQueue::AsyncNext
NextStatus AsyncNext(void **tag, bool *ok, const T &deadline)
Definition: include/grpcpp/impl/codegen/completion_queue.h:202
GRPC_CQ_NON_POLLING
@ GRPC_CQ_NON_POLLING
Definition: grpc_types.h:754
grpc::Server::SyncRequestThreadManager::DoWork
void DoWork(void *tag, bool ok, bool resources) override
Definition: server_cc.cc:808
grpc::Service
Desriptor of an RPC service and its various RPC methods.
Definition: grpcpp/impl/codegen/service_type.h:58
gpr_once_init
GPRAPI void gpr_once_init(gpr_once *once, void(*init_function)(void))
grpc::Server::SyncRequest::ContinueRunAfterInterception
void ContinueRunAfterInterception()
Definition: server_cc.cc:455
grpc_types.h
grpc::Server::SyncRequest::server_
Server *const server_
Definition: server_cc.cc:508
grpc::Server::initializer
ServerInitializer * initializer()
Definition: server_cc.cc:1362
grpc::PayloadHandlingForMethod
static grpc_server_register_method_payload_handling PayloadHandlingForMethod(grpc::internal::RpcServiceMethod *method)
Definition: server_cc.cc:1013
grpc_metadata_array_destroy
GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array *array)
Definition: metadata_array.cc:35
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:661
grpc::Server::SyncRequestThreadManager
Definition: server_cc.cc:776
grpc::ServerInterface::GenericAsyncRequest::call_details_
grpc_call_details call_details_
Definition: grpcpp/impl/codegen/server_interface.h:311
grpc_iomgr_run_in_background
bool grpc_iomgr_run_in_background()
grpc_server_request_call
GRPCAPI grpc_call_error grpc_server_request_call(grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new)
Definition: src/core/lib/surface/server.cc:1526
grpc::Server::CallbackRequest::deadline_
gpr_timespec deadline_
Definition: server_cc.cc:730
client_interceptor.h
grpc::internal::RpcServiceMethod
Server side rpc method class.
Definition: grpcpp/impl/codegen/rpc_service_method.h:86
grpc::internal::GrpcLibraryInitializer
Instantiating this class ensures the proper initialization of gRPC.
Definition: grpcpp/impl/grpc_library.h:39
grpc::internal::RpcMethod::NORMAL_RPC
@ NORMAL_RPC
Definition: grpcpp/impl/codegen/rpc_method.h:34
grpc::Server::UnimplementedAsyncRequest::stream
grpc::GenericServerAsyncReaderWriter * stream()
Definition: server_cc.cc:336
grpc::CompletionQueue::cq
grpc_completion_queue * cq()
Definition: include/grpcpp/impl/codegen/completion_queue.h:249
grpc::kHealthCheckServiceInterfaceArg
const char kHealthCheckServiceInterfaceArg[]
Definition: grpcpp/health_check_service_interface.h:26
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
sync.h
grpc::Server::CallbackCQ
CompletionQueue * CallbackCQ() ABSL_LOCKS_EXCLUDED(mu_) override
Definition: server_cc.cc:1366
GRPC_CQ_DEFAULT_POLLING
@ GRPC_CQ_DEFAULT_POLLING
Definition: grpc_types.h:743
grpc::Server::SyncRequestThreadManager::AddSyncMethod
void AddSyncMethod(grpc::internal::RpcServiceMethod *method, void *tag)
Definition: server_cc.cc:821
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
channel_arguments.h
grpc_core::Server::SetRegisteredMethodAllocator
void SetRegisteredMethodAllocator(grpc_completion_queue *cq, void *method_tag, std::function< RegisteredCallAllocation()> allocator)
Definition: src/core/lib/surface/server.cc:643
grpc::Server::SyncRequest
Definition: server_cc.cc:365
context_
ScopedContext * context_
Definition: filter_fuzzer.cc:559
grpc::Server::SyncRequestThreadManager::Wait
void Wait() override
Definition: server_cc.cc:850
grpc::Server::CallbackRequest::CallbackCallTag::call_
grpc::internal::Call * call_
Definition: server_cc.cc:626
grpc_resource_quota_set_max_threads
GRPCAPI void grpc_resource_quota_set_max_threads(grpc_resource_quota *resource_quota, int new_max_threads)
Definition: api.cc:91
grpc::testing::SERVER_STREAMING
@ SERVER_STREAMING
Definition: stress_interop_client.h:44
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc::Server::SyncRequest::ServerContextWrapper::ServerContextWrapper
ServerContextWrapper(gpr_timespec deadline, grpc_metadata_array *arr)
Definition: server_cc.cc:528
grpc_call_unref
GRPCAPI void grpc_call_unref(grpc_call *call)
Definition: call.cc:1770
req
static uv_connect_t req
Definition: test-connection-fail.c:30
grpc::ServerInterface::BaseAsyncRequest::call_
grpc_call * call_
Definition: grpcpp/impl/codegen/server_interface.h:189
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_core::Server::RegisteredCallAllocation
Definition: src/core/lib/surface/server.h:97
grpc::ServerCredentials
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: include/grpcpp/security/server_credentials.h:76
GPR_UNLIKELY
#define GPR_UNLIKELY(x)
Definition: impl/codegen/port_platform.h:770
grpc::ServerCredentials::AddPortToServer
virtual int AddPortToServer(const std::string &addr, grpc_server *server)=0
grpc::Server::SyncRequest::request_metadata_
grpc_metadata_array request_metadata_
Definition: server_cc.cc:514
grpc.h
grpc_call
struct grpc_call grpc_call
Definition: grpc_types.h:70
grpc_byte_buffer
Definition: grpc_types.h:43
grpc::internal::InterceptorBatchMethodsImpl::SetReverse
void SetReverse()
Definition: interceptor_common.h:209
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: include/grpcpp/impl/codegen/call.h:67
grpc::Server::CallbackRequest::has_request_payload_
const bool has_request_payload_
Definition: server_cc.cc:723
grpc::ServerInterface::BaseAsyncRequest::call_wrapper_
internal::Call call_wrapper_
Definition: grpcpp/impl/codegen/server_interface.h:190
grpc::Server::CallbackRequest::CallbackCallTag::ContinueRunAfterInterception
void ContinueRunAfterInterception()
Definition: server_cc.cc:695
completion_queue.h
completion_queue_tag.h
started_
bool started_
Definition: xds_cluster_impl.cc:357
grpc::CompletionQueue::CallbackAlternativeCQ
static CompletionQueue * CallbackAlternativeCQ()
Definition: completion_queue_cc.cc:196
grpc_channel_args::num_args
size_t num_args
Definition: grpc_types.h:133
channel.h
grpc::Server::CallbackRequest::CallbackRequest
CallbackRequest(Server *server, grpc::CompletionQueue *cq, grpc_core::Server::BatchCallAllocation *data)
Definition: server_cc.cc:568
grpc::Server::CallbackRequest::default_ctx_
grpc_core::ManualConstructor< ServerContextType > default_ctx_
Definition: server_cc.cc:736
grpc::DefaultHealthCheckService
Definition: default_health_check_service.h:48
grpc_arg::grpc_arg_value::grpc_arg_pointer::p
void * p
Definition: grpc_types.h:110
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition: gpr_types.h:36
grpc_server
struct grpc_server grpc_server
Definition: grpc_types.h:65
grpc::ServerInterface::GenericAsyncRequest::GenericAsyncRequest
GenericAsyncRequest(ServerInterface *server, GenericServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag, bool delete_on_finalize)
Definition: server_cc.cc:250
grpc::ServerInterface
Definition: grpcpp/impl/codegen/server_interface.h:61
grpc::Server::SyncRequestThreadManager::PollForWork
WorkStatus PollForWork(void **tag, bool *ok) override
Definition: server_cc.cc:788
grpc::Server::SyncRequest::wrapped_call_
grpc_core::ManualConstructor< internal::Call > wrapped_call_
Definition: server_cc.cc:533
grpc::Server::SyncRequest::deadline_
gpr_timespec deadline_
Definition: server_cc.cc:513
error.h
benchmark::Initialize
void Initialize(int *argc, char **argv)
Definition: benchmark/src/benchmark.cc:602
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
grpc_server_destroy
GRPCAPI void grpc_server_destroy(grpc_server *server)
Definition: src/core/lib/surface/server.cc:1519
callback
static void callback(void *arg, int status, int timeouts, struct hostent *host)
Definition: acountry.c:224
benchmark::Shutdown
void Shutdown()
Definition: benchmark/src/benchmark.cc:607
grpc::Server::CallbackRequest::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
GPR_UNREACHABLE_CODE
#define GPR_UNREACHABLE_CODE(STATEMENT)
Definition: impl/codegen/port_platform.h:652
grpc::ServerInterface::interceptor_creators
virtual std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface > > * interceptor_creators()
Definition: grpcpp/impl/codegen/server_interface.h:354
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
grpc_core::ExecCtx
Definition: exec_ctx.h:97
call_op_set_interface.h
config.h
grpc::Server::CallbackRequest::method_name
const char * method_name() const
grpc::internal::ReleasableMutexLock::Release
void Release() ABSL_UNLOCK_FUNCTION()
Definition: include/grpcpp/impl/codegen/sync.h:113
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: include/grpcpp/impl/codegen/call.h:37
grpc_completion_queue_attributes
Definition: grpc_types.h:791
manual_constructor.h
grpc::Server::CallbackRequest::~CallbackRequest
~CallbackRequest() override
Definition: server_cc.cc:585
grpc::internal::CallOpSet
Definition: call_op_set.h:859
grpc.StatusCode.UNIMPLEMENTED
tuple UNIMPLEMENTED
Definition: src/python/grpcio/grpc/__init__.py:276
grpc::internal::RpcMethod::RpcType
RpcType
Definition: grpcpp/impl/codegen/rpc_method.h:33
grpc::internal::InterceptorBatchMethodsImpl::SetCall
void SetCall(Call *call)
Definition: interceptor_common.h:216
grpc::Server::CallbackRequest::request_status_
grpc::Status request_status_
Definition: server_cc.cc:727
grpc::HealthCheckServiceInterface
Definition: grpcpp/health_check_service_interface.h:31
grpc::CallbackGenericService
Definition: grpcpp/impl/codegen/async_generic_service.h:104
server_interceptor.h
server_credentials.h
grpc_server_cancel_all_calls
GRPCAPI void grpc_server_cancel_all_calls(grpc_server *server)
Definition: src/core/lib/surface/server.cc:1512
grpc::Server::SyncRequestThreadManager::cq_timeout_msec_
int cq_timeout_msec_
Definition: server_cc.cc:871
grpc::ServerAsyncReaderWriter::call_
grpc::internal::Call call_
Definition: grpcpp/impl/codegen/async_stream.h:1117
grpc::ServerInterface::BaseAsyncRequest::interceptor_methods_
internal::InterceptorBatchMethodsImpl interceptor_methods_
Definition: grpcpp/impl/codegen/server_interface.h:191
gpr_types.h
request_
EchoRequest request_
Definition: client_callback_end2end_test.cc:724
grpc::Server::SyncRequest::SyncRequest
SyncRequest(Server *server, grpc::internal::RpcServiceMethod *method, grpc_core::Server::BatchCallAllocation *data)
Definition: server_cc.cc:375
grpc::Server::CallbackRequest::CallbackCallTag::Run
void Run(bool ok)
Definition: server_cc.cc:631
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
grpc::Server::SyncRequestThreadManager::Shutdown
void Shutdown() override
Definition: server_cc.cc:845
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::Server::CallbackRequest::CallbackCallTag::CallbackCallTag
CallbackCallTag(Server::CallbackRequest< ServerContextType > *req)
Definition: server_cc.cc:607
grpc::Server::SyncRequestThreadManager::global_callbacks_
std::shared_ptr< Server::GlobalCallbacks > global_callbacks_
Definition: server_cc.cc:874
grpc::Server::SyncRequest::ServerContextWrapper::ctx
ServerContext ctx
Definition: server_cc.cc:526
grpc::Server::GlobalCallbacks
Definition: include/grpcpp/server.h:75
grpc::Server::CallbackRequest::call_
grpc_call * call_
Definition: server_cc.cc:729
grpc::ThreadManager::Wait
virtual void Wait()
Definition: thread_manager.cc:76
grpc::Server::SyncRequest::SyncRequest
SyncRequest(Server *server, grpc::internal::RpcServiceMethod *method)
Definition: server_cc.cc:489
grpc::Server::callback_cq_
std::atomic< CompletionQueue * > callback_cq_
Definition: include/grpcpp/server.h:337
grpc::internal::ServerAsyncStreamingInterface
Definition: grpcpp/impl/codegen/service_type.h:39
grpc_cq_begin_op
bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag)
Definition: completion_queue.cc:672
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
grpc::CompletionQueue::Next
bool Next(void **tag, bool *ok)
Definition: include/grpcpp/impl/codegen/completion_queue.h:179
shutdown_
bool shutdown_
Definition: pick_first.cc:173
grpc::Server::SyncRequest::FinalizeResult
bool FinalizeResult(void **, bool *status) override
Definition: server_cc.cc:399
call.h
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:219
grpc::ServerInterface::BaseAsyncRequest
Definition: grpcpp/impl/codegen/server_interface.h:167
grpc::Server::SyncRequestThreadManager::unknown_method_
std::unique_ptr< grpc::internal::RpcServiceMethod > unknown_method_
Definition: server_cc.cc:873
grpc::ServerInterface::BaseAsyncRequest::ContinueFinalizeResultAfterInterception
void ContinueFinalizeResultAfterInterception()
Definition: server_cc.cc:217
grpc_library.h
gpr_time_add
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:135
grpc::Server::UnimplementedAsyncResponse::request_
UnimplementedAsyncRequest *const request_
Definition: server_cc.cc:362
server
Definition: examples/python/async_streaming/server.py:1
grpc::Server::SyncRequest::interceptor_methods_
grpc::internal::InterceptorBatchMethodsImpl interceptor_methods_
Definition: server_cc.cc:521
tests.unit._server_ssl_cert_config_test.Call
Call
Definition: _server_ssl_cert_config_test.py:70
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
grpc::Server
Definition: include/grpcpp/server.h:59
GRPC_CQ_CURRENT_VERSION
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:789
client.handler
handler
Definition: examples/python/multiprocessing/client.py:87
grpc::internal::ErrorMethodHandler::FillOps
static void FillOps(grpc::ServerContextBase *context, const std::string &message, T *ops)
Definition: impl/codegen/method_handler.h:362
grpc_resource_quota_unref
GRPCAPI void grpc_resource_quota_unref(grpc_resource_quota *resource_quota)
Definition: api.cc:79
server_context.h
call_op_set.h
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
grpc::CompletionQueue::TIMEOUT
@ TIMEOUT
deadline was reached.
Definition: include/grpcpp/impl/codegen/completion_queue.h:128
grpc::internal::ReleasableMutexLock
Definition: include/grpcpp/impl/codegen/sync.h:100
grpc_arg::key
char * key
Definition: grpc_types.h:105
grpc::CompletionQueue::Shutdown
void Shutdown()
Definition: completion_queue_cc.cc:137
grpc_server_shutdown_and_notify
GRPCAPI void grpc_server_shutdown_and_notify(grpc_server *server, grpc_completion_queue *cq, void *tag)
Definition: src/core/lib/surface/server.cc:1503
server_callback_handlers.h
grpc_byte_buffer_destroy
GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)
Definition: byte_buffer.cc:81
grpc::internal::MethodHandler::HandlerParameter
Definition: grpcpp/impl/codegen/rpc_service_method.h:43
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
service_type.h
ok
bool ok
Definition: async_end2end_test.cc:197
grpc_completion_queue_functor
Definition: grpc_types.h:773
exec_ctx.h
grpc::ServerInterface::BaseAsyncRequest::~BaseAsyncRequest
~BaseAsyncRequest() override
Definition: server_cc.cc:166
server.h
grpc::ServerInterface::BaseAsyncRequest::BaseAsyncRequest
BaseAsyncRequest(ServerInterface *server, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag, bool delete_on_finalize)
Definition: server_cc.cc:145
grpc::ServerInterface::GenericAsyncRequest::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
Definition: server_cc.cc:267
grpc::ThreadManager
Definition: src/cpp/thread_manager/thread_manager.h:31
server_interface.h
grpc::Server::UnimplementedAsyncResponse
Definition: server_cc.cc:341
gpr_time_from_millis
GPRAPI gpr_timespec gpr_time_from_millis(int64_t ms, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:119
grpc::GenericServerAsyncReaderWriter
ServerAsyncReaderWriter< ByteBuffer, ByteBuffer > GenericServerAsyncReaderWriter
Definition: grpcpp/impl/codegen/async_generic_service.h:36
TIMEOUT
#define TIMEOUT
Definition: test-loop-handles.c:75
grpc::Server::SyncRequestThreadManager::server_
Server * server_
Definition: server_cc.cc:869
grpc::ServerInterface::BaseAsyncRequest::call_cq_
grpc::CompletionQueue *const call_cq_
Definition: grpcpp/impl/codegen/server_interface.h:185
grpc_server_set_config_fetcher
GRPCAPI void grpc_server_set_config_fetcher(grpc_server *server, grpc_server_config_fetcher *config_fetcher)
Definition: src/core/lib/surface/server.cc:1571
GPR_DEBUG
#define GPR_DEBUG
Definition: include/grpc/impl/codegen/log.h:55
grpc::DefaultHealthCheckService::HealthCheckServiceImpl
Definition: default_health_check_service.h:53
internal
Definition: benchmark/test/output_test_helper.cc:20
GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER
@ GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER
Definition: grpc.h:400
tag_
void * tag_
Definition: channel_connectivity.cc:211
grpc::Server::SyncRequest::ctx_
grpc_core::ManualConstructor< ServerContextWrapper > ctx_
Definition: server_cc.cc:532
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
method_handler.h
grpc::Server::SyncRequest::cq_
grpc::CompletionQueue cq_
Definition: server_cc.cc:516
grpc::GenericCallbackServerContext
Definition: grpcpp/impl/codegen/async_generic_service.h:89
GRPC_CQ_CALLBACK
@ GRPC_CQ_CALLBACK
Definition: grpc_types.h:766
grpc::Server::UnimplementedAsyncResponse::~UnimplementedAsyncResponse
~UnimplementedAsyncResponse() override
Definition: server_cc.cc:347
grpc::CompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:104
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
server.h
gpr_timespec
Definition: gpr_types.h:50
grpc::Server::SyncRequest::call_
grpc_call * call_
Definition: server_cc.cc:511
grpc::Server::CallbackRequest::server_
Server *const server_
Definition: server_cc.cc:721
grpc_arg::grpc_arg_value::integer
int integer
Definition: grpc_types.h:108
googletest-break-on-failure-unittest.Run
def Run(command)
Definition: bloaty/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py:76
grpc_server_start
GRPCAPI void grpc_server_start(grpc_server *server)
Definition: src/core/lib/surface/server.cc:1497
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
grpc::internal::CompletionQueueTag
An interface allowing implementors to process and filter event tags.
Definition: grpcpp/impl/codegen/completion_queue_tag.h:28
grpc::DefaultHealthCheckService::HealthCheckServiceImpl::StartServingThread
void StartServingThread()
Definition: default_health_check_service.cc:184
grpc::Server::CallbackRequest::CallbackCallTag::req_
Server::CallbackRequest< ServerContextType > * req_
Definition: server_cc.cc:625
grpc::ThreadManager::WorkStatus
WorkStatus
Definition: src/cpp/thread_manager/thread_manager.h:41
grpc::ServerInterface::RegisteredAsyncRequest::IssueRequest
void IssueRequest(void *registered_method, grpc_byte_buffer **payload, grpc::ServerCompletionQueue *notification_cq)
Definition: server_cc.cc:238
grpc::internal::RpcMethod::BIDI_STREAMING
@ BIDI_STREAMING
Definition: grpcpp/impl/codegen/rpc_method.h:37
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
testing::Ref
internal::RefMatcher< T & > Ref(T &x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8628
method
NSString * method
Definition: ProtoMethod.h:28
grpc_core::CppImplOf< Server, grpc_server >::FromC
static Server * FromC(grpc_server *c_type)
Definition: cpp_impl_of.h:30
grpc::internal::RpcMethod::SERVER_STREAMING
@ SERVER_STREAMING
Definition: grpcpp/impl/codegen/rpc_method.h:36
grpc::Server::CallbackRequest
Definition: include/grpcpp/server.h:226
grpc::internal::RpcMethod::CLIENT_STREAMING
@ CLIENT_STREAMING
Definition: grpcpp/impl/codegen/rpc_method.h:35
grpc::Server::SyncRequestThreadManager::server_cq_
grpc::CompletionQueue * server_cq_
Definition: server_cc.cc:870
grpc::Server::SyncRequest::ServerContextWrapper
Definition: server_cc.cc:525
gen_server_registered_method_bad_client_test_body.payload
list payload
Definition: gen_server_registered_method_bad_client_test_body.py:40
grpc::ServerInitializer
Definition: grpcpp/impl/server_initializer.h:31
grpc_channel_args::args
grpc_arg * args
Definition: grpc_types.h:134
sync.h
ops
static grpc_op ops[6]
Definition: test/core/fling/client.cc:39
method_name
absl::string_view method_name
Definition: call_creds_util.cc:40
default_health_check_service.h
grpc::experimental::InterceptionHookPoints
InterceptionHookPoints
Definition: impl/codegen/interceptor.h:59
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
grpc::Server::SyncRequestThreadManager::AddUnknownSyncMethod
void AddUnknownSyncMethod()
Definition: server_cc.cc:831
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
grpc::DefaultHealthCheckServiceEnabled
bool DefaultHealthCheckServiceEnabled()
Definition: health_check_service.cc:26
grpc::Server::SyncRequest::has_request_payload_
const bool has_request_payload_
Definition: server_cc.cc:510
grpc::Server::CallbackRequest::CommonSetup
void CommonSetup(Server *server, CallAllocation *data)
Definition: server_cc.cc:706
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
grpc_inproc_channel_create
grpc_channel * grpc_inproc_channel_create(grpc_server *server, const grpc_channel_args *args, void *)
Definition: inproc_transport.cc:1247
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
grpc::Server::SyncRequest::SyncRequest
SyncRequest(Server *server, grpc::internal::RpcServiceMethod *method, grpc_core::Server::RegisteredCallAllocation *data)
Definition: server_cc.cc:367
grpc::StringFromCopiedSlice
std::string StringFromCopiedSlice(grpc_slice slice)
Definition: include/grpcpp/impl/codegen/slice.h:139
grpc_metadata_array_init
GRPCAPI void grpc_metadata_array_init(grpc_metadata_array *array)
Definition: metadata_array.cc:30
grpc_server_register_method
GRPCAPI void * grpc_server_register_method(grpc_server *server, const char *method, const char *host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags)
Definition: src/core/lib/surface/server.cc:1485
grpc::Server::SyncRequest::request_status_
grpc::Status request_status_
Definition: server_cc.cc:517
grpc::ServerInterface::GenericAsyncRequest
Definition: grpcpp/impl/codegen/server_interface.h:300
status.h
grpc_core::ManualConstructor
Definition: manual_constructor.h:103
api.h
grpc::Server::UnimplementedAsyncRequest::context
grpc::ServerContext * context()
Definition: server_cc.cc:335
grpc::Server::SyncRequest::resources_
bool resources_
Definition: server_cc.cc:519
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:17