diff options
author | Muxi Yan <mxyan@google.com> | 2017-12-06 22:29:12 -0800 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-12-06 22:29:12 -0800 |
commit | 6043006af142fd2e10372ce5ef74f56b3064ce43 (patch) | |
tree | 35b85d640b0e78e227a9f09f48ce06725b6aa7c1 /include | |
parent | 67454d71e833a7704d61e673ad32e71dd31c868a (diff) | |
parent | 84d78acfa41a1263ba75b46dd4e857e02ea2cb96 (diff) |
Merge remote-tracking branch 'upstream/master' into fix-stream-compression-config-interface
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 6 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/completion_queue.h | 32 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/core_codegen_interface.h | 4 | ||||
-rw-r--r-- | include/grpc++/server_builder.h | 146 | ||||
-rw-r--r-- | include/grpc/fork.h | 24 | ||||
-rw-r--r-- | include/grpc/grpc_security.h | 2 | ||||
-rw-r--r-- | include/grpc/impl/codegen/fork.h | 48 | ||||
-rw-r--r-- | include/grpc/impl/codegen/grpc_types.h | 7 | ||||
-rw-r--r-- | include/grpc/impl/codegen/port_platform.h | 23 | ||||
-rw-r--r-- | include/grpc/module.modulemap | 4 | ||||
-rw-r--r-- | include/grpc/support/alloc.h | 2 | ||||
-rw-r--r-- | include/grpc/support/histogram.h | 64 | ||||
-rw-r--r-- | include/grpc/support/log.h | 2 | ||||
-rw-r--r-- | include/grpc/support/thd.h | 5 | ||||
-rw-r--r-- | include/grpc/support/tls_gcc.h | 40 |
15 files changed, 213 insertions, 196 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 63caf90d39..1c7f9b3d00 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -296,11 +296,6 @@ class CallOpSendMessage { WriteOptions write_options_; }; -namespace internal { -template <class T> -T Example(); -} // namespace internal - template <class M> Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) { write_options_ = options; @@ -562,6 +557,7 @@ class CallOpClientRecvStatus { op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr(); op->data.recv_status_on_client.status = &status_code_; op->data.recv_status_on_client.status_details = &error_message_; + op->data.recv_status_on_client.error_string = nullptr; op->flags = 0; op->reserved = NULL; } diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 11cc588879..b8a7862578 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -65,6 +65,7 @@ class CompletionQueue; class Server; class ServerBuilder; class ServerContext; +class ServerInterface; namespace internal { class CompletionQueueTag; @@ -187,21 +188,6 @@ class CompletionQueue : private GrpcLibraryCodegen { /// owership is performed. grpc_completion_queue* cq() { return cq_; } - /// Manage state of avalanching operations : completion queue tags that - /// trigger other completion queue operations. The underlying core completion - /// queue should not really shutdown until all avalanching operations have - /// been finalized. Note that we maintain the requirement that an avalanche - /// registration must take place before CQ shutdown (which must be maintained - /// elsehwere) - void InitialAvalanching() { - gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1)); - } - void RegisterAvalanching() { - gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, - static_cast<gpr_atm>(1)); - } - void CompleteAvalanching(); - protected: /// Private constructor of CompletionQueue only visible to friend classes CompletionQueue(const grpc_completion_queue_attributes& attributes) { @@ -238,6 +224,7 @@ class CompletionQueue : private GrpcLibraryCodegen { friend class ::grpc::internal::UnknownMethodHandler; friend class ::grpc::Server; friend class ::grpc::ServerContext; + friend class ::grpc::ServerInterface; template <class InputMessage, class OutputMessage> friend class ::grpc::internal::BlockingUnaryCallImpl; @@ -309,6 +296,21 @@ class CompletionQueue : private GrpcLibraryCodegen { GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); } + /// Manage state of avalanching operations : completion queue tags that + /// trigger other completion queue operations. The underlying core completion + /// queue should not really shutdown until all avalanching operations have + /// been finalized. Note that we maintain the requirement that an avalanche + /// registration must take place before CQ shutdown (which must be maintained + /// elsehwere) + void InitialAvalanching() { + gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1)); + } + void RegisterAvalanching() { + gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast<gpr_atm>(1)); + } + void CompleteAvalanching(); + grpc_completion_queue* cq_; // owned gpr_atm avalanches_in_flight_; diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index 1949cdab76..d7ad7a4b57 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -25,10 +25,6 @@ #include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/sync.h> -extern "C" { -struct grpc_byte_buffer; -} - namespace grpc { /// Interface between the codegen library and the minimal subset of core diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 0888bef0d9..e2bae4b41f 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -55,13 +55,18 @@ class ServerBuilder { ServerBuilder(); ~ServerBuilder(); - /// Options for synchronous servers. - enum SyncServerOption { - NUM_CQS, ///< Number of completion queues. - MIN_POLLERS, ///< Minimum number of polling threads. - MAX_POLLERS, ///< Maximum number of polling threads. - CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds. - }; + ////////////////////////////////////////////////////////////////////////////// + // Primary API's + + /// Return a running server which is ready for processing calls. + /// Before calling, one typically needs to ensure that: + /// 1. a service is registered - so that the server knows what to serve + /// (via RegisterService, or RegisterAsyncGenericService) + /// 2. a listening port has been added - so the server knows where to receive + /// traffic (via AddListeningPort) + /// 3. [for async api only] completion queues have been added via + /// AddCompletionQueue + std::unique_ptr<Server> BuildAndStart(); /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the \a Server instance returned @@ -69,9 +74,60 @@ class ServerBuilder { /// Matches requests with any :authority ServerBuilder& RegisterService(Service* service); - /// Register a generic service. - /// Matches requests with any :authority - ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service); + /// Enlists an endpoint \a addr (port with an optional IP address) to + /// bind the \a grpc::Server object to be created to. + /// + /// It can be invoked multiple times. + /// + /// \param addr_uri The address to try to bind to the server in URI form. If + /// the scheme name is omitted, "dns:///" is assumed. To bind to any address, + /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4 + /// connections. Valid values include dns:///localhost:1234, / + /// 192.168.1.1:31416, dns:///[::1]:27182, etc.). + /// \param creds The credentials associated with the server. + /// \param selected_port[out] If not `nullptr`, gets populated with the port + /// number bound to the \a grpc::Server for the corresponding endpoint after + /// it is successfully bound, 0 otherwise. + /// + ServerBuilder& AddListeningPort(const grpc::string& addr_uri, + std::shared_ptr<ServerCredentials> creds, + int* selected_port = nullptr); + + /// Add a completion queue for handling asynchronous services. + /// + /// Best performance is typically obtained by using one thread per polling + /// completion queue. + /// + /// Caller is required to shutdown the server prior to shutting down the + /// returned completion queue. Caller is also required to drain the + /// completion queue after shutting it down. A typical usage scenario: + /// + /// // While building the server: + /// ServerBuilder builder; + /// ... + /// cq_ = builder.AddCompletionQueue(); + /// server_ = builder.BuildAndStart(); + /// + /// // While shutting down the server; + /// server_->Shutdown(); + /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()! + /// // Drain the cq_ that was created + /// void* ignored_tag; + /// bool ignored_ok; + /// while (cq_->Next(&ignored_tag, &ignored_ok)) { } + /// + /// \param is_frequently_polled This is an optional parameter to inform gRPC + /// library about whether this completion queue would be frequently polled + /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is + /// 'true' and is the recommended setting. Setting this to 'false' (i.e. + /// not polling the completion queue frequently) will have a significantly + /// negative performance impact and hence should not be used in production + /// use cases. + std::unique_ptr<ServerCompletionQueue> AddCompletionQueue( + bool is_frequently_polled = true); + + ////////////////////////////////////////////////////////////////////////////// + // Less commonly used RegisterService variants /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the \a Server instance returned @@ -79,6 +135,15 @@ class ServerBuilder { /// Only matches requests with :authority \a host ServerBuilder& RegisterService(const grpc::string& host, Service* service); + /// Register a generic service. + /// Matches requests with any :authority + /// This is mostly useful for writing generic gRPC Proxies where the exact + /// serialization format is unknown + ServerBuilder& RegisterAsyncGenericService(AsyncGenericService* service); + + ////////////////////////////////////////////////////////////////////////////// + // Fine control knobs + /// Set max receive message size in bytes. ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) { max_receive_message_size_ = max_receive_message_size; @@ -119,6 +184,14 @@ class ServerBuilder { ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option); + /// Options for synchronous servers. + enum SyncServerOption { + NUM_CQS, ///< Number of completion queues. + MIN_POLLERS, ///< Minimum number of polling threads. + MAX_POLLERS, ///< Maximum number of polling threads. + CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds. + }; + /// Only useful if this is a Synchronous server. ServerBuilder& SetSyncServerOption(SyncServerOption option, int value); @@ -129,59 +202,6 @@ class ServerBuilder { return SetOption(MakeChannelArgumentOption(arg, value)); } - /// Enlists an endpoint \a addr (port with an optional IP address) to - /// bind the \a grpc::Server object to be created to. - /// - /// It can be invoked multiple times. - /// - /// \param addr_uri The address to try to bind to the server in URI form. If - /// the scheme name is omitted, "dns:///" is assumed. To bind to any address, - /// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4 - /// connections. Valid values include dns:///localhost:1234, / - /// 192.168.1.1:31416, dns:///[::1]:27182, etc.). - /// \param creds The credentials associated with the server. - /// \param selected_port[out] If not `nullptr`, gets populated with the port - /// number bound to the \a grpc::Server for the corresponding endpoint after - /// it is successfully bound, 0 otherwise. - /// - // TODO(dgq): the "port" part seems to be a misnomer. - ServerBuilder& AddListeningPort(const grpc::string& addr_uri, - std::shared_ptr<ServerCredentials> creds, - int* selected_port = nullptr); - - /// Add a completion queue for handling asynchronous services. - /// - /// Caller is required to shutdown the server prior to shutting down the - /// returned completion queue. Caller is also required to drain the - /// completion queue after shutting it down. A typical usage scenario: - /// - /// // While building the server: - /// ServerBuilder builder; - /// ... - /// cq_ = builder.AddCompletionQueue(); - /// server_ = builder.BuildAndStart(); - /// - /// // While shutting down the server; - /// server_->Shutdown(); - /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()! - /// // Drain the cq_ that was created - /// void* ignored_tag; - /// bool ignored_ok; - /// while (cq_->Next(&ignored_tag, &ignored_ok)) { } - /// - /// \param is_frequently_polled This is an optional parameter to inform gRPC - /// library about whether this completion queue would be frequently polled - /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is - /// 'true' and is the recommended setting. Setting this to 'false' (i.e. - /// not polling the completion queue frequently) will have a significantly - /// negative performance impact and hence should not be used in production - /// use cases. - std::unique_ptr<ServerCompletionQueue> AddCompletionQueue( - bool is_frequently_polled = true); - - /// Return a running server which is ready for processing calls. - std::unique_ptr<Server> BuildAndStart(); - /// For internal use only: Register a ServerBuilderPlugin factory function. static void InternalAddPluginFactory( std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)()); diff --git a/include/grpc/fork.h b/include/grpc/fork.h new file mode 100644 index 0000000000..ca45e1139c --- /dev/null +++ b/include/grpc/fork.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_FORK_H +#define GRPC_FORK_H + +#include <grpc/impl/codegen/fork.h> + +#endif /* GRPC_FORK_H */ diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 7e87217de7..bae07ac309 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -185,7 +185,7 @@ GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create( GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create( void* reserved); -GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(); +GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(void); /** Creates a JWT credentials object. May return NULL if the input is invalid. - json_key is the JSON key string containing the client's private key. diff --git a/include/grpc/impl/codegen/fork.h b/include/grpc/impl/codegen/fork.h new file mode 100644 index 0000000000..baec7a2f10 --- /dev/null +++ b/include/grpc/impl/codegen/fork.h @@ -0,0 +1,48 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_IMPL_CODEGEN_FORK_H +#define GRPC_IMPL_CODEGEN_FORK_H + +/** + * gRPC applications should call this before calling fork(). There should be no + * active gRPC function calls between calling grpc_prefork() and + * grpc_postfork_parent()/grpc_postfork_child(). + * + * + * Typical use: + * grpc_prefork(); + * int pid = fork(); + * if (pid) { + * grpc_postfork_parent(); + * // Parent process.. + * } else { + * grpc_postfork_child(); + * // Child process... + * } + */ + +void grpc_prefork(); + +void grpc_postfork_parent(); + +void grpc_postfork_child(); + +void grpc_fork_handlers_auto_register(); + +#endif /* GRPC_IMPL_CODEGEN_FORK_H */ diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 90d96bb0d2..559996658f 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -240,6 +240,9 @@ typedef struct { /** The time between the first and second connection attempts, in ms */ #define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ "grpc.initial_reconnect_backoff_ms" +/** The timeout used on servers for finishing handshaking on an incoming + connection. Defaults to 120 seconds. */ +#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" /** This *should* be used for testing only. The caller of the secure_channel_create functions may override the target name used for SSL host name checking using this channel argument which is of @@ -554,6 +557,10 @@ typedef struct grpc_op { grpc_metadata_array* trailing_metadata; grpc_status_code* status; grpc_slice* status_details; + /** If this is not nullptr, it will be populated with the full fidelity + * error string for debugging purposes. The application is responsible + * for freeing the data by using gpr_free(). */ + const char** error_string; } recv_status_on_client; struct grpc_op_recv_close_on_server { /** out argument, set to 1 if the call failed in any way (seen as a diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index fb4bfc3162..5a0ed85111 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -173,6 +173,7 @@ #endif /* _LP64 */ #ifdef __GLIBC__ #define GPR_POSIX_CRASH_HANDLER 1 +#define GPR_LINUX_PTHREAD_NAME 1 #else /* musl libc */ #define GPR_MUSL_LIBC_COMPAT 1 #endif @@ -195,6 +196,7 @@ #else /* __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 */ #define GPR_CPU_POSIX 1 #define GPR_GCC_TLS 1 +#define GPR_APPLE_PTHREAD_NAME 1 #endif #else /* __MAC_OS_X_VERSION_MIN_REQUIRED */ #define GPR_CPU_POSIX 1 @@ -297,6 +299,27 @@ #endif #endif /* GPR_NO_AUTODETECT_PLATFORM */ +/* + * There are platforms for which TLS should not be used even though the + * compiler makes it seem like it's supported (Android NDK < r12b for example). + * This is primarily because of linker problems and toolchain misconfiguration: + * TLS isn't supported until NDK r12b per + * https://developer.android.com/ndk/downloads/revision_history.html + * Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in + * <android/ndk-version.h>. For NDK < r16, users should define these macros, + * e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. */ +#if defined(__ANDROID__) && defined(__clang__) && defined(GPR_GCC_TLS) +#if __has_include(<android/ndk-version.h>) +#include <android/ndk-version.h> +#endif /* __has_include(<android/ndk-version.h>) */ +#if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ + defined(__NDK_MINOR__) && \ + ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) +#undef GPR_GCC_TLS +#define GPR_PTHREAD_TLS 1 +#endif +#endif /*defined(__ANDROID__) && defined(__clang__) && defined(GPR_GCC_TLS) */ + #if defined(__has_include) #if __has_include(<atomic>) #define GRPC_HAS_CXX11_ATOMIC diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 65de47f938..7b7b623dfd 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -7,7 +7,6 @@ framework module grpc { header "support/avl.h" header "support/cmdline.h" header "support/cpu.h" - header "support/histogram.h" header "support/host_port.h" header "support/log.h" header "support/log_windows.h" @@ -21,6 +20,7 @@ framework module grpc { header "support/tls.h" header "support/useful.h" header "impl/codegen/atm.h" + header "impl/codegen/fork.h" header "impl/codegen/gpr_slice.h" header "impl/codegen/gpr_types.h" header "impl/codegen/port_platform.h" @@ -36,6 +36,7 @@ framework module grpc { header "impl/codegen/slice.h" header "impl/codegen/status.h" header "impl/codegen/atm.h" + header "impl/codegen/fork.h" header "impl/codegen/gpr_slice.h" header "impl/codegen/gpr_types.h" header "impl/codegen/port_platform.h" @@ -46,6 +47,7 @@ framework module grpc { header "byte_buffer_reader.h" header "compression.h" header "compression_ruby.h" + header "fork.h" header "grpc.h" header "grpc_posix.h" header "grpc_security_constants.h" diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 31cb225638..c559198237 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -58,7 +58,7 @@ GPRAPI void gpr_free_aligned(void* ptr); GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions); /** Return the family of allocation functions currently in effect. */ -GPRAPI gpr_allocation_functions gpr_get_allocation_functions(); +GPRAPI gpr_allocation_functions gpr_get_allocation_functions(void); #ifdef __cplusplus } diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h deleted file mode 100644 index d2794d847e..0000000000 --- a/include/grpc/support/histogram.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_SUPPORT_HISTOGRAM_H -#define GRPC_SUPPORT_HISTOGRAM_H - -#include <grpc/support/port_platform.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct gpr_histogram gpr_histogram; - -GPRAPI gpr_histogram* gpr_histogram_create(double resolution, - double max_bucket_start); -GPRAPI void gpr_histogram_destroy(gpr_histogram* h); -GPRAPI void gpr_histogram_add(gpr_histogram* h, double x); - -/** The following merges the second histogram into the first. It only works - if they have the same buckets and resolution. Returns 0 on failure, 1 - on success */ -GPRAPI int gpr_histogram_merge(gpr_histogram* dst, const gpr_histogram* src); - -GPRAPI double gpr_histogram_percentile(gpr_histogram* histogram, - double percentile); -GPRAPI double gpr_histogram_mean(gpr_histogram* histogram); -GPRAPI double gpr_histogram_stddev(gpr_histogram* histogram); -GPRAPI double gpr_histogram_variance(gpr_histogram* histogram); -GPRAPI double gpr_histogram_maximum(gpr_histogram* histogram); -GPRAPI double gpr_histogram_minimum(gpr_histogram* histogram); -GPRAPI double gpr_histogram_count(gpr_histogram* histogram); -GPRAPI double gpr_histogram_sum(gpr_histogram* histogram); -GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram* histogram); - -GPRAPI const uint32_t* gpr_histogram_get_contents(gpr_histogram* histogram, - size_t* count); -GPRAPI void gpr_histogram_merge_contents(gpr_histogram* histogram, - const uint32_t* data, - size_t data_count, double min_seen, - double max_seen, double sum, - double sum_of_squares, double count); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_HISTOGRAM_H */ diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 497cca9081..9cce4b1ae7 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -68,7 +68,7 @@ GPRAPI void gpr_log_message(const char* file, int line, /** Set global log verbosity */ GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print); -GPRAPI void gpr_log_verbosity_init(); +GPRAPI void gpr_log_verbosity_init(void); /** Log overrides: applications can use this API to intercept logging calls and use their own implementations */ diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index 225d9d6c75..e9444e88c9 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -42,9 +42,12 @@ typedef struct { /** Create a new thread running (*thd_body)(arg) and place its thread identifier in *t, and return true. If there are insufficient resources, return false. + thd_name is the name of the thread for identification purposes on platforms + that support thread naming. If options==NULL, default options are used. The thread is immediately runnable, and exits when (*thd_body)() returns. */ -GPRAPI int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg, +GPRAPI int gpr_thd_new(gpr_thd_id* t, const char* thd_name, + void (*thd_body)(void* arg), void* arg, const gpr_thd_options* options); /** Return a gpr_thd_options struct with all fields set to defaults. */ diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h index 019acdf122..1b91d22be1 100644 --- a/include/grpc/support/tls_gcc.h +++ b/include/grpc/support/tls_gcc.h @@ -26,44 +26,6 @@ /** Thread local storage based on gcc compiler primitives. #include tls.h to use this - and see that file for documentation */ -#ifndef NDEBUG - -struct gpr_gcc_thread_local { - intptr_t value; - bool* inited; -}; - -#define GPR_TLS_DECL(name) \ - static bool name##_inited = false; \ - static __thread struct gpr_gcc_thread_local name = {0, &(name##_inited)} - -#define gpr_tls_init(tls) \ - do { \ - GPR_ASSERT(*((tls)->inited) == false); \ - *((tls)->inited) = true; \ - } while (0) - -/** It is allowed to call gpr_tls_init after gpr_tls_destroy is called. */ -#define gpr_tls_destroy(tls) \ - do { \ - GPR_ASSERT(*((tls)->inited)); \ - *((tls)->inited) = false; \ - } while (0) - -#define gpr_tls_set(tls, new_value) \ - do { \ - GPR_ASSERT(*((tls)->inited)); \ - (tls)->value = (new_value); \ - } while (0) - -#define gpr_tls_get(tls) \ - ({ \ - GPR_ASSERT(*((tls)->inited)); \ - (tls)->value; \ - }) - -#else /* NDEBUG */ - struct gpr_gcc_thread_local { intptr_t value; }; @@ -80,6 +42,4 @@ struct gpr_gcc_thread_local { #define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value)) #define gpr_tls_get(tls) ((tls)->value) -#endif /* NDEBUG */ - #endif /* GRPC_SUPPORT_TLS_GCC_H */ |