aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-01-15 11:46:40 -0800
committerGravatar yang-g <yangg@google.com>2016-01-15 11:46:40 -0800
commit1ac6f4594e52040a6525b1e333c1beb4b2d48fcb (patch)
tree9c5b6f4874df19c032935dc9e85862efd439e531 /include
parentc021c9be5b1b969bd8ca82918962b4bb4a4d767e (diff)
warn user when they forget register generic service
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/impl/service_type.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h
index 4925785fd4..27af88e16f 100644
--- a/include/grpc++/impl/service_type.h
+++ b/include/grpc++/impl/service_type.h
@@ -82,6 +82,15 @@ class Service {
return false;
}
+ bool has_generic_methods() const {
+ for (auto it = methods_.begin(); it != methods_.end(); ++it) {
+ if ((*it)->get() == nullptr) {
+ return true;
+ }
+ }
+ return false;
+ }
+
protected:
template <class Message>
void RequestAsyncUnary(int index, ServerContext* context, Message* request,
@@ -122,16 +131,15 @@ class Service {
void MarkMethodAsync(int index) {
if (methods_[index].get() == nullptr) {
- gpr_log(GPR_ERROR, "A method cannot be marked async and generic.");
- abort();
+ gpr_log(GPR_ERROR, "Method already marked generic.");
+ return;
}
methods_[index]->ResetHandler();
}
void MarkMethodGeneric(int index) {
if (methods_[index]->handler() == nullptr) {
- gpr_log(GPR_ERROR, "A method cannot be marked async and generic.");
- abort();
+ gpr_log(GPR_ERROR, "Method already marked async.");
}
methods_[index].reset();
}