diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc/grpc.h | 6 | ||||
-rw-r--r-- | include/grpc/impl/codegen/port_platform.h | 41 | ||||
-rw-r--r-- | include/grpcpp/impl/codegen/service_type.h | 37 | ||||
-rw-r--r-- | include/grpcpp/opencensus.h | 11 |
4 files changed, 82 insertions, 13 deletions
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 897b89851a..4e50cd0bac 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -79,6 +79,12 @@ GRPCAPI void grpc_init(void); destroyed. */ GRPCAPI void grpc_shutdown(void); +/** EXPERIMENTAL. Returns 1 if the grpc library has been initialized. + TODO(ericgribkoff) Decide if this should be promoted to non-experimental as + part of stabilizing the fork support API, as tracked in + https://github.com/grpc/grpc/issues/15334 */ +GRPCAPI int grpc_is_initialized(void); + /** Return a string representing the current version of grpc */ GRPCAPI const char* grpc_version_string(void); diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index 2b61a8816d..8d9bd83285 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -282,6 +282,47 @@ #else /* _LP64 */ #define GPR_ARCH_32 1 #endif /* _LP64 */ +#elif defined(__sun) && defined(__SVR4) +#define GPR_PLATFORM_STRING "solaris" +#define GPR_SOLARIS 1 +#define GPR_CPU_POSIX 1 +#define GPR_GCC_ATOMIC 1 +#define GPR_GCC_TLS 1 +#define GPR_POSIX_LOG 1 +#define GPR_POSIX_ENV 1 +#define GPR_POSIX_TMPFILE 1 +#define GPR_POSIX_STRING 1 +#define GPR_POSIX_SUBPROCESS 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 +#ifdef _LP64 +#define GPR_ARCH_64 1 +#else /* _LP64 */ +#define GPR_ARCH_32 1 +#endif /* _LP64 */ +#elif defined(_AIX) +#define GPR_PLATFORM_STRING "aix" +#ifndef _ALL_SOURCE +#define _ALL_SOURCE +#endif +#define GPR_AIX 1 +#define GPR_CPU_POSIX 1 +#define GPR_GCC_ATOMIC 1 +#define GPR_GCC_TLS 1 +#define GPR_POSIX_LOG 1 +#define GPR_POSIX_ENV 1 +#define GPR_POSIX_TMPFILE 1 +#define GPR_POSIX_STRING 1 +#define GPR_POSIX_SUBPROCESS 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 +#ifdef _LP64 +#define GPR_ARCH_64 1 +#else /* _LP64 */ +#define GPR_ARCH_32 1 +#endif /* _LP64 */ #elif defined(__native_client__) #define GPR_PLATFORM_STRING "nacl" #ifndef _BSD_SOURCE diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index a0bbd659e2..9f1a052168 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -93,14 +93,19 @@ class Service { internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { - server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq, + // Typecast the index to size_t for indexing into a vector + // while preserving the API that existed before a compiler + // warning was first seen (grpc/grpc#11664) + size_t idx = static_cast<size_t>(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag, request); } void RequestAsyncClientStreaming( int index, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { - server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq, + size_t idx = static_cast<size_t>(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); } template <class Message> @@ -108,14 +113,16 @@ class Service { int index, ServerContext* context, Message* request, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { - server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq, + size_t idx = static_cast<size_t>(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag, request); } void RequestAsyncBidiStreaming( int index, ServerContext* context, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag) { - server_->RequestAsyncCall(methods_[index].get(), context, stream, call_cq, + size_t idx = static_cast<size_t>(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, notification_cq, tag); } @@ -126,46 +133,50 @@ class Service { void MarkMethodAsync(int index) { // This does not have to be a hard error, however no one has approached us // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast<size_t>(index); GPR_CODEGEN_ASSERT( - methods_[index].get() != nullptr && + methods_[idx].get() != nullptr && "Cannot mark the method as 'async' because it has already been " "marked as 'generic'."); - methods_[index]->SetServerAsyncType( + methods_[idx]->SetServerAsyncType( internal::RpcServiceMethod::AsyncType::ASYNC); } void MarkMethodRaw(int index) { // This does not have to be a hard error, however no one has approached us // with a use case yet. Please file an issue if you believe you have one. - GPR_CODEGEN_ASSERT(methods_[index].get() != nullptr && + size_t idx = static_cast<size_t>(index); + GPR_CODEGEN_ASSERT(methods_[idx].get() != nullptr && "Cannot mark the method as 'raw' because it has already " "been marked as 'generic'."); - methods_[index]->SetServerAsyncType( + methods_[idx]->SetServerAsyncType( internal::RpcServiceMethod::AsyncType::RAW); } void MarkMethodGeneric(int index) { // This does not have to be a hard error, however no one has approached us // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast<size_t>(index); GPR_CODEGEN_ASSERT( - methods_[index]->handler() != nullptr && + methods_[idx]->handler() != nullptr && "Cannot mark the method as 'generic' because it has already been " "marked as 'async' or 'raw'."); - methods_[index].reset(); + methods_[idx].reset(); } void MarkMethodStreamed(int index, internal::MethodHandler* streamed_method) { // This does not have to be a hard error, however no one has approached us // with a use case yet. Please file an issue if you believe you have one. - GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && + size_t idx = static_cast<size_t>(index); + GPR_CODEGEN_ASSERT(methods_[idx] && methods_[idx]->handler() && "Cannot mark an async or generic method Streamed"); - methods_[index]->SetHandler(streamed_method); + methods_[idx]->SetHandler(streamed_method); // From the server's point of view, streamed unary is a special // case of BIDI_STREAMING that has 1 read and 1 write, in that order, // and split server-side streaming is BIDI_STREAMING with 1 read and // any number of writes, in that order. - methods_[index]->SetMethodType(internal::RpcMethod::BIDI_STREAMING); + methods_[idx]->SetMethodType(internal::RpcMethod::BIDI_STREAMING); } private: diff --git a/include/grpcpp/opencensus.h b/include/grpcpp/opencensus.h index 7e5d1dfeb4..07a1333986 100644 --- a/include/grpcpp/opencensus.h +++ b/include/grpcpp/opencensus.h @@ -19,6 +19,12 @@ #ifndef GRPCPP_OPENCENSUS_H #define GRPCPP_OPENCENSUS_H +#ifndef GRPC_BAZEL_BUILD +#error OpenCensus for gRPC is only supported when building with bazel. +#endif + +#include "opencensus/trace/span.h" + namespace grpc { // These symbols in this file will not be included in the binary unless // grpc_opencensus_plugin build target was added as a dependency. At the moment @@ -36,6 +42,11 @@ void RegisterOpenCensusPlugin(); // ViewDescriptors below. void RegisterOpenCensusViewsForExport(); +class ServerContext; + +// Returns the tracing Span for the current RPC. +::opencensus::trace::Span GetSpanFromServerContext(ServerContext* context); + } // namespace grpc #endif // GRPCPP_OPENCENSUS_H |