aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-08-24 12:05:13 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2015-08-24 12:08:38 -0700
commitc43648f250dd6cb0f086e2366e468372a6de26ae (patch)
tree0353cb50e39de0338553b97e5fcb1276f48cf4a5 /include
parentbeac88ca56f4710e86668f2cbbd80e02e0607f9c (diff)
parent04715888e60c6195a2c1d9d6b31f7a82f0d717e2 (diff)
Merge branch 'master' of github.com:grpc/grpc into compression-accept-encoding
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/async_unary_call.h4
-rw-r--r--include/grpc++/auth_context.h34
-rw-r--r--include/grpc++/auth_property_iterator.h77
-rw-r--r--include/grpc++/byte_buffer.h4
-rw-r--r--include/grpc++/client_context.h8
-rw-r--r--include/grpc++/completion_queue.h2
-rw-r--r--include/grpc++/dynamic_thread_pool.h9
-rw-r--r--include/grpc++/generic_stub.h4
-rw-r--r--include/grpc++/impl/README.md4
-rw-r--r--include/grpc++/impl/call.h32
-rw-r--r--include/grpc++/impl/grpc_library.h1
-rw-r--r--include/grpc++/impl/rpc_service_method.h15
-rw-r--r--include/grpc++/impl/serialization_traits.h6
-rw-r--r--include/grpc++/impl/sync_no_cxx11.h8
-rw-r--r--include/grpc++/impl/thd_no_cxx11.h21
-rw-r--r--include/grpc++/server.h18
-rw-r--r--include/grpc++/server_builder.h12
-rw-r--r--include/grpc++/server_context.h2
-rw-r--r--include/grpc++/stream.h9
-rw-r--r--include/grpc/byte_buffer.h4
-rw-r--r--include/grpc/census.h55
-rw-r--r--include/grpc/compression.h4
-rw-r--r--include/grpc/grpc.h100
-rw-r--r--include/grpc/grpc_zookeeper.h (renamed from include/grpc/support/cancellable_platform.h)41
-rw-r--r--include/grpc/status.h2
-rw-r--r--include/grpc/support/alloc.h2
-rw-r--r--include/grpc/support/atm.h2
-rw-r--r--include/grpc/support/atm_gcc_atomic.h2
-rw-r--r--include/grpc/support/atm_gcc_sync.h2
-rw-r--r--include/grpc/support/atm_win32.h37
-rw-r--r--include/grpc/support/cmdline.h2
-rw-r--r--include/grpc/support/cpu.h2
-rw-r--r--include/grpc/support/histogram.h2
-rw-r--r--include/grpc/support/host_port.h2
-rw-r--r--include/grpc/support/log.h2
-rw-r--r--include/grpc/support/log_win32.h2
-rw-r--r--include/grpc/support/port_platform.h5
-rw-r--r--include/grpc/support/slice.h2
-rw-r--r--include/grpc/support/string_util.h2
-rw-r--r--include/grpc/support/subprocess.h2
-rw-r--r--include/grpc/support/sync.h35
-rw-r--r--include/grpc/support/sync_generic.h14
-rw-r--r--include/grpc/support/sync_posix.h2
-rw-r--r--include/grpc/support/sync_win32.h2
-rw-r--r--include/grpc/support/thd.h2
-rw-r--r--include/grpc/support/time.h3
-rw-r--r--include/grpc/support/tls.h4
-rw-r--r--include/grpc/support/tls_gcc.h10
-rw-r--r--include/grpc/support/tls_msvc.h10
-rw-r--r--include/grpc/support/useful.h10
50 files changed, 348 insertions, 288 deletions
diff --git a/include/grpc++/async_unary_call.h b/include/grpc++/async_unary_call.h
index d631ccd134..3d22df4b33 100644
--- a/include/grpc++/async_unary_call.h
+++ b/include/grpc++/async_unary_call.h
@@ -121,8 +121,8 @@ class ServerAsyncResponseWriter GRPC_FINAL
}
// The response is dropped if the status is not OK.
if (status.ok()) {
- finish_buf_.ServerSendStatus(
- ctx_->trailing_metadata_, finish_buf_.SendMessage(msg));
+ finish_buf_.ServerSendStatus(ctx_->trailing_metadata_,
+ finish_buf_.SendMessage(msg));
} else {
finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status);
}
diff --git a/include/grpc++/auth_context.h b/include/grpc++/auth_context.h
index c42105b927..7dced90ce5 100644
--- a/include/grpc++/auth_context.h
+++ b/include/grpc++/auth_context.h
@@ -34,12 +34,43 @@
#ifndef GRPCXX_AUTH_CONTEXT_H
#define GRPCXX_AUTH_CONTEXT_H
+#include <iterator>
#include <vector>
-#include <grpc++/auth_property_iterator.h>
#include <grpc++/config.h>
+struct grpc_auth_context;
+struct grpc_auth_property;
+struct grpc_auth_property_iterator;
+
namespace grpc {
+class SecureAuthContext;
+
+typedef std::pair<grpc::string, grpc::string> AuthProperty;
+
+class AuthPropertyIterator
+ : public std::iterator<std::input_iterator_tag, const AuthProperty> {
+ public:
+ ~AuthPropertyIterator();
+ AuthPropertyIterator& operator++();
+ AuthPropertyIterator operator++(int);
+ bool operator==(const AuthPropertyIterator& rhs) const;
+ bool operator!=(const AuthPropertyIterator& rhs) const;
+ const AuthProperty operator*();
+
+ protected:
+ AuthPropertyIterator();
+ AuthPropertyIterator(const grpc_auth_property* property,
+ const grpc_auth_property_iterator* iter);
+
+ private:
+ friend class SecureAuthContext;
+ const grpc_auth_property* property_;
+ // The following items form a grpc_auth_property_iterator.
+ const grpc_auth_context* ctx_;
+ size_t index_;
+ const char* name_;
+};
class AuthContext {
public:
@@ -62,4 +93,3 @@ class AuthContext {
} // namespace grpc
#endif // GRPCXX_AUTH_CONTEXT_H
-
diff --git a/include/grpc++/auth_property_iterator.h b/include/grpc++/auth_property_iterator.h
deleted file mode 100644
index c7870c46be..0000000000
--- a/include/grpc++/auth_property_iterator.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GRPCXX_AUTH_PROPERTY_ITERATOR_H
-#define GRPCXX_AUTH_PROPERTY_ITERATOR_H
-
-#include <iterator>
-#include <vector>
-
-#include <grpc++/config.h>
-
-struct grpc_auth_context;
-struct grpc_auth_property;
-struct grpc_auth_property_iterator;
-
-namespace grpc {
-class SecureAuthContext;
-
-typedef std::pair<grpc::string, grpc::string> AuthProperty;
-
-class AuthPropertyIterator
- : public std::iterator<std::input_iterator_tag, const AuthProperty> {
- public:
- ~AuthPropertyIterator();
- AuthPropertyIterator& operator++();
- AuthPropertyIterator operator++(int);
- bool operator==(const AuthPropertyIterator& rhs) const;
- bool operator!=(const AuthPropertyIterator& rhs) const;
- const AuthProperty operator*();
-
- protected:
- AuthPropertyIterator();
- AuthPropertyIterator(const grpc_auth_property* property,
- const grpc_auth_property_iterator* iter);
- private:
- friend class SecureAuthContext;
- const grpc_auth_property* property_;
- // The following items form a grpc_auth_property_iterator.
- const grpc_auth_context* ctx_;
- size_t index_;
- const char* name_;
-};
-
-} // namespace grpc
-
- #endif // GRPCXX_AUTH_PROPERTY_ITERATOR_H
-
diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h
index cb3c6a1159..6467776398 100644
--- a/include/grpc++/byte_buffer.h
+++ b/include/grpc++/byte_buffer.h
@@ -91,8 +91,8 @@ class SerializationTraits<ByteBuffer, void> {
dest->set_buffer(byte_buffer);
return Status::OK;
}
- static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
- bool* own_buffer) {
+ static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
+ bool* own_buffer) {
*buffer = source.buffer();
*own_buffer = false;
return Status::OK;
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h
index 5137bf6a1a..8de2ba4877 100644
--- a/include/grpc++/client_context.h
+++ b/include/grpc++/client_context.h
@@ -185,7 +185,9 @@ class ClientContext {
// Get and set census context
void set_census_context(struct census_context* ccp) { census_context_ = ccp; }
- struct census_context* census_context() const { return census_context_; }
+ struct census_context* census_context() const {
+ return census_context_;
+ }
void TryCancel();
@@ -223,15 +225,11 @@ class ClientContext {
void set_call(grpc_call* call,
const std::shared_ptr<ChannelInterface>& channel);
- grpc_completion_queue* cq() { return cq_; }
- void set_cq(grpc_completion_queue* cq) { cq_ = cq; }
-
grpc::string authority() { return authority_; }
bool initial_metadata_received_;
std::shared_ptr<ChannelInterface> channel_;
grpc_call* call_;
- grpc_completion_queue* cq_;
gpr_timespec deadline_;
grpc::string authority_;
std::shared_ptr<Credentials> creds_;
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h
index 0523ab6a0e..2f30211145 100644
--- a/include/grpc++/completion_queue.h
+++ b/include/grpc++/completion_queue.h
@@ -63,6 +63,7 @@ template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
+class UnknownMethodHandler;
class ChannelInterface;
class ClientContext;
@@ -138,6 +139,7 @@ class CompletionQueue : public GrpcLibrary {
friend class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
friend class BidiStreamingHandler;
+ friend class UnknownMethodHandler;
friend class ::grpc::Server;
friend class ::grpc::ServerContext;
template <class InputMessage, class OutputMessage>
diff --git a/include/grpc++/dynamic_thread_pool.h b/include/grpc++/dynamic_thread_pool.h
index f0cd35940f..a4d4885b51 100644
--- a/include/grpc++/dynamic_thread_pool.h
+++ b/include/grpc++/dynamic_thread_pool.h
@@ -55,11 +55,12 @@ class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface {
private:
class DynamicThread {
- public:
- DynamicThread(DynamicThreadPool *pool);
+ public:
+ DynamicThread(DynamicThreadPool* pool);
~DynamicThread();
- private:
- DynamicThreadPool *pool_;
+
+ private:
+ DynamicThreadPool* pool_;
std::unique_ptr<grpc::thread> thd_;
void ThreadFunc();
};
diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h
index c34e1fcf55..172f10e45a 100644
--- a/include/grpc++/generic_stub.h
+++ b/include/grpc++/generic_stub.h
@@ -52,8 +52,8 @@ class GenericStub GRPC_FINAL {
// begin a call to a named method
std::unique_ptr<GenericClientAsyncReaderWriter> Call(
- ClientContext* context, const grpc::string& method,
- CompletionQueue* cq, void* tag);
+ ClientContext* context, const grpc::string& method, CompletionQueue* cq,
+ void* tag);
private:
std::shared_ptr<ChannelInterface> channel_;
diff --git a/include/grpc++/impl/README.md b/include/grpc++/impl/README.md
new file mode 100644
index 0000000000..612150caa0
--- /dev/null
+++ b/include/grpc++/impl/README.md
@@ -0,0 +1,4 @@
+**The APIs in this directory are not stable!**
+
+This directory contains header files that need to be installed but are not part
+of the public API. Users should not use these headers directly.
diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h
index 1fa4490779..bc1db4c12c 100644
--- a/include/grpc++/impl/call.h
+++ b/include/grpc++/impl/call.h
@@ -67,14 +67,10 @@ class WriteOptions {
WriteOptions(const WriteOptions& other) : flags_(other.flags_) {}
/// Clear all flags.
- inline void Clear() {
- flags_ = 0;
- }
+ inline void Clear() { flags_ = 0; }
/// Returns raw flags bitset.
- inline gpr_uint32 flags() const {
- return flags_;
- }
+ inline gpr_uint32 flags() const { return flags_; }
/// Sets flag for the disabling of compression for the next message write.
///
@@ -122,9 +118,7 @@ class WriteOptions {
/// not go out on the wire immediately.
///
/// \sa GRPC_WRITE_BUFFER_HINT
- inline bool get_buffer_hint() const {
- return GetBit(GRPC_WRITE_BUFFER_HINT);
- }
+ inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
WriteOptions& operator=(const WriteOptions& rhs) {
flags_ = rhs.flags_;
@@ -132,17 +126,11 @@ class WriteOptions {
}
private:
- void SetBit(const gpr_int32 mask) {
- flags_ |= mask;
- }
+ void SetBit(const gpr_int32 mask) { flags_ |= mask; }
- void ClearBit(const gpr_int32 mask) {
- flags_ &= ~mask;
- }
+ void ClearBit(const gpr_int32 mask) { flags_ &= ~mask; }
- bool GetBit(const gpr_int32 mask) const {
- return flags_ & mask;
- }
+ bool GetBit(const gpr_int32 mask) const { return flags_ & mask; }
gpr_uint32 flags_;
};
@@ -173,6 +161,7 @@ class CallOpSendInitialMetadata {
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->flags = 0;
+ op->reserved = NULL;
op->data.send_initial_metadata.count = initial_metadata_count_;
op->data.send_initial_metadata.metadata = initial_metadata_;
}
@@ -206,6 +195,7 @@ class CallOpSendMessage {
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_SEND_MESSAGE;
op->flags = write_options_.flags();
+ op->reserved = NULL;
op->data.send_message = send_buf_;
// Flags are per-message: clear them after use.
write_options_.Clear();
@@ -248,6 +238,7 @@ class CallOpRecvMessage {
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_RECV_MESSAGE;
op->flags = 0;
+ op->reserved = NULL;
op->data.recv_message = &recv_buf_;
}
@@ -313,6 +304,7 @@ class CallOpGenericRecvMessage {
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_RECV_MESSAGE;
op->flags = 0;
+ op->reserved = NULL;
op->data.recv_message = &recv_buf_;
}
@@ -350,6 +342,7 @@ class CallOpClientSendClose {
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
+ op->reserved = NULL;
}
void FinishOp(bool* status, int max_message_size) { send_ = false; }
@@ -383,6 +376,7 @@ class CallOpServerSendStatus {
op->data.send_status_from_server.status_details =
send_status_details_.empty() ? nullptr : send_status_details_.c_str();
op->flags = 0;
+ op->reserved = NULL;
}
void FinishOp(bool* status, int max_message_size) {
@@ -416,6 +410,7 @@ class CallOpRecvInitialMetadata {
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata = &recv_initial_metadata_arr_;
op->flags = 0;
+ op->reserved = NULL;
}
void FinishOp(bool* status, int max_message_size) {
if (recv_initial_metadata_ == nullptr) return;
@@ -453,6 +448,7 @@ class CallOpClientRecvStatus {
op->data.recv_status_on_client.status_details_capacity =
&status_details_capacity_;
op->flags = 0;
+ op->reserved = NULL;
}
void FinishOp(bool* status, int max_message_size) {
diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h
index f9fa677901..ce4211418d 100644
--- a/include/grpc++/impl/grpc_library.h
+++ b/include/grpc++/impl/grpc_library.h
@@ -46,5 +46,4 @@ class GrpcLibrary {
} // namespace grpc
-
#endif // GRPCXX_IMPL_GRPC_LIBRARY_H
diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h
index 3cfbef7806..925801e1ce 100644
--- a/include/grpc++/impl/rpc_service_method.h
+++ b/include/grpc++/impl/rpc_service_method.h
@@ -208,6 +208,21 @@ class BidiStreamingHandler : public MethodHandler {
ServiceType* service_;
};
+// Handle unknown method by returning UNIMPLEMENTED error.
+class UnknownMethodHandler : public MethodHandler {
+ public:
+ void RunHandler(const HandlerParameter& param) GRPC_FINAL {
+ Status status(StatusCode::UNIMPLEMENTED, "");
+ CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops;
+ if (!param.server_context->sent_initial_metadata_) {
+ ops.SendInitialMetadata(param.server_context->initial_metadata_);
+ }
+ ops.ServerSendStatus(param.server_context->trailing_metadata_, status);
+ param.call->PerformOps(&ops);
+ param.call->cq()->Pluck(&ops);
+ }
+};
+
// Server side rpc method class
class RpcServiceMethod : public RpcMethod {
public:
diff --git a/include/grpc++/impl/serialization_traits.h b/include/grpc++/impl/serialization_traits.h
index 1f5c674e4c..3ea66a3405 100644
--- a/include/grpc++/impl/serialization_traits.h
+++ b/include/grpc++/impl/serialization_traits.h
@@ -37,12 +37,12 @@
namespace grpc {
/// Defines how to serialize and deserialize some type.
-///
+///
/// Used for hooking different message serialization API's into GRPC.
/// Each SerializationTraits implementation must provide the following
/// functions:
/// static Status Serialize(const Message& msg,
-/// grpc_byte_buffer** buffer,
+/// grpc_byte_buffer** buffer,
// bool* own_buffer);
/// static Status Deserialize(grpc_byte_buffer* buffer,
/// Message* msg,
@@ -57,7 +57,7 @@ namespace grpc {
/// msg. max_message_size is passed in as a bound on the maximum number of
/// message bytes Deserialize should accept.
///
-/// Both functions return a Status, allowing them to explain what went
+/// Both functions return a Status, allowing them to explain what went
/// wrong if required.
template <class Message,
class UnusedButHereForPartialTemplateSpecialization = void>
diff --git a/include/grpc++/impl/sync_no_cxx11.h b/include/grpc++/impl/sync_no_cxx11.h
index 5869b04c76..120a031045 100644
--- a/include/grpc++/impl/sync_no_cxx11.h
+++ b/include/grpc++/impl/sync_no_cxx11.h
@@ -38,7 +38,7 @@
namespace grpc {
-template<class mutex>
+template <class mutex>
class lock_guard;
class condition_variable;
@@ -46,6 +46,7 @@ class mutex {
public:
mutex() { gpr_mu_init(&mu_); }
~mutex() { gpr_mu_destroy(&mu_); }
+
private:
::gpr_mu mu_;
template <class mutex>
@@ -58,6 +59,7 @@ class lock_guard {
public:
lock_guard(mutex &mu) : mu_(mu), locked(true) { gpr_mu_lock(&mu.mu_); }
~lock_guard() { unlock_internal(); }
+
protected:
void lock_internal() {
if (!locked) gpr_mu_lock(&mu_.mu_);
@@ -67,6 +69,7 @@ class lock_guard {
if (locked) gpr_mu_unlock(&mu_.mu_);
locked = false;
}
+
private:
mutex &mu_;
bool locked;
@@ -76,7 +79,7 @@ class lock_guard {
template <class mutex>
class unique_lock : public lock_guard<mutex> {
public:
- unique_lock(mutex &mu) : lock_guard<mutex>(mu) { }
+ unique_lock(mutex &mu) : lock_guard<mutex>(mu) {}
void lock() { this->lock_internal(); }
void unlock() { this->unlock_internal(); }
};
@@ -92,6 +95,7 @@ class condition_variable {
}
void notify_one() { gpr_cv_signal(&cv_); }
void notify_all() { gpr_cv_broadcast(&cv_); }
+
private:
gpr_cv cv_;
};
diff --git a/include/grpc++/impl/thd_no_cxx11.h b/include/grpc++/impl/thd_no_cxx11.h
index a6bdd7dfe9..84d03ce184 100644
--- a/include/grpc++/impl/thd_no_cxx11.h
+++ b/include/grpc++/impl/thd_no_cxx11.h
@@ -40,7 +40,8 @@ namespace grpc {
class thread {
public:
- template<class T> thread(void (T::*fptr)(), T *obj) {
+ template <class T>
+ thread(void (T::*fptr)(), T *obj) {
func_ = new thread_function<T>(fptr, obj);
joined_ = false;
start();
@@ -53,28 +54,28 @@ class thread {
gpr_thd_join(thd_);
joined_ = true;
}
+
private:
void start() {
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
- gpr_thd_new(&thd_, thread_func, (void *) func_, &options);
+ gpr_thd_new(&thd_, thread_func, (void *)func_, &options);
}
static void thread_func(void *arg) {
- thread_function_base *func = (thread_function_base *) arg;
+ thread_function_base *func = (thread_function_base *)arg;
func->call();
}
class thread_function_base {
public:
- virtual ~thread_function_base() { }
+ virtual ~thread_function_base() {}
virtual void call() = 0;
};
- template<class T>
+ template <class T>
class thread_function : public thread_function_base {
public:
- thread_function(void (T::*fptr)(), T *obj)
- : fptr_(fptr)
- , obj_(obj) { }
+ thread_function(void (T::*fptr)(), T *obj) : fptr_(fptr), obj_(obj) {}
virtual void call() { (obj_->*fptr_)(); }
+
private:
void (T::*fptr_)();
T *obj_;
@@ -84,8 +85,8 @@ class thread {
bool joined_;
// Disallow copy and assign.
- thread(const thread&);
- void operator=(const thread&);
+ thread(const thread &);
+ void operator=(const thread &);
};
} // namespace grpc
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index 07dbd7fd20..3e8b6a976a 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -64,7 +64,14 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
~Server();
// Shutdown the server, block until all rpc processing finishes.
- void Shutdown();
+ // Forcefully terminate pending calls after deadline expires.
+ template <class T>
+ void Shutdown(const T& deadline) {
+ ShutdownInternal(TimePoint<T>(deadline).raw_time());
+ }
+
+ // Shutdown the server, waiting for all rpc processing to finish.
+ void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); }
// Block waiting for all work to complete (the server must either
// be shutting down or some other thread must call Shutdown for this
@@ -85,8 +92,9 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
int max_message_size, grpc_compression_options compression_options);
// Register a service. This call does not take ownership of the service.
// The service must exist for the lifetime of the Server instance.
- bool RegisterService(const grpc::string *host, RpcService* service);
- bool RegisterAsyncService(const grpc::string *host, AsynchronousService* service);
+ bool RegisterService(const grpc::string* host, RpcService* service);
+ bool RegisterAsyncService(const grpc::string* host,
+ AsynchronousService* service);
void RegisterAsyncGenericService(AsyncGenericService* service);
// Add a listening port. Can be called multiple times.
int AddListeningPort(const grpc::string& addr, ServerCredentials* creds);
@@ -99,6 +107,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE;
+ void ShutdownInternal(gpr_timespec deadline);
+
class BaseAsyncRequest : public CompletionQueueTag {
public:
BaseAsyncRequest(Server* server, ServerContext* context,
@@ -229,6 +239,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
grpc::condition_variable callback_cv_;
std::list<SyncRequest>* sync_methods_;
+ std::unique_ptr<RpcServiceMethod> unknown_method_;
+ bool has_generic_service_;
// Pointer to the c grpc server.
grpc_server* const server_;
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 47efbb7834..f1a713a487 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -78,7 +78,7 @@ class ServerBuilder {
// BuildAndStart().
// Only matches requests with :authority \a host
ServerBuilder& RegisterService(const grpc::string& host,
- SynchronousService* service);
+ SynchronousService* service);
// Register an asynchronous service.
// This call does not take ownership of the service or completion queue.
@@ -86,7 +86,7 @@ class ServerBuilder {
// instance returned by BuildAndStart().
// Only matches requests with :authority \a host
ServerBuilder& RegisterAsyncService(const grpc::string& host,
- AsynchronousService* service);
+ AsynchronousService* service);
// Set max message size in bytes.
ServerBuilder& SetMaxMessageSize(int max_message_size);
@@ -119,9 +119,10 @@ class ServerBuilder {
};
typedef std::unique_ptr<grpc::string> HostString;
- template <class T> struct NamedService {
+ template <class T>
+ struct NamedService {
explicit NamedService(T* s) : service(s) {}
- NamedService(const grpc::string& h, T *s)
+ NamedService(const grpc::string& h, T* s)
: host(new grpc::string(h)), service(s) {}
HostString host;
T* service;
@@ -130,7 +131,8 @@ class ServerBuilder {
int max_message_size_;
grpc_compression_options compression_options_;
std::vector<std::unique_ptr<NamedService<RpcService>>> services_;
- std::vector<std::unique_ptr<NamedService<AsynchronousService>>> async_services_;
+ std::vector<std::unique_ptr<NamedService<AsynchronousService>>>
+ async_services_;
std::vector<Port> ports_;
std::vector<ServerCompletionQueue*> cqs_;
std::shared_ptr<ServerCredentials> creds_;
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index 2296835461..b87a1f0379 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -73,6 +73,7 @@ template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
+class UnknownMethodHandler;
class Call;
class CallOpBuffer;
@@ -159,6 +160,7 @@ class ServerContext {
friend class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
friend class BidiStreamingHandler;
+ friend class UnknownMethodHandler;
friend class ::grpc::ClientContext;
// Prevent copying.
diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h
index bc0c3c0f3b..45dafcd282 100644
--- a/include/grpc++/stream.h
+++ b/include/grpc++/stream.h
@@ -85,9 +85,7 @@ class WriterInterface {
// Returns false when the stream has been closed.
virtual bool Write(const W& msg, const WriteOptions& options) = 0;
- inline bool Write(const W& msg) {
- return Write(msg, WriteOptions());
- }
+ inline bool Write(const W& msg) { return Write(msg, WriteOptions()); }
};
template <class R>
@@ -640,9 +638,8 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface,
}
// The response is dropped if the status is not OK.
if (status.ok()) {
- finish_ops_.ServerSendStatus(
- ctx_->trailing_metadata_,
- finish_ops_.SendMessage(msg));
+ finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
+ finish_ops_.SendMessage(msg));
} else {
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
}
diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h
index 913e2a7697..1433ffdf7e 100644
--- a/include/grpc/byte_buffer.h
+++ b/include/grpc/byte_buffer.h
@@ -47,9 +47,13 @@ typedef enum {
} grpc_byte_buffer_type;
struct grpc_byte_buffer {
+ void *reserved;
grpc_byte_buffer_type type;
union {
struct {
+ void *reserved[8];
+ } reserved;
+ struct {
grpc_compression_algorithm compression;
gpr_slice_buffer slice_buffer;
} raw;
diff --git a/include/grpc/census.h b/include/grpc/census.h
index 7603dfdce1..a18b997b79 100644
--- a/include/grpc/census.h
+++ b/include/grpc/census.h
@@ -104,6 +104,61 @@ int census_context_deserialize(const char *buffer, census_context **context);
* future census calls will result in undefined behavior. */
void census_context_destroy(census_context *context);
+/* Max number of characters in tag key */
+#define CENSUS_MAX_TAG_KEY_LENGTH 20
+/* Max number of tag value characters */
+#define CENSUS_MAX_TAG_VALUE_LENGTH 50
+
+/* A Census tag set is a collection of key:value string pairs; these form the
+ basis against which Census metrics will be recorded. Keys are unique within
+ a tag set. All contexts have an associated tag set. */
+typedef struct census_tag_set census_tag_set;
+
+/* Returns a pointer to a newly created, empty tag set. If size_hint > 0,
+ indicates that the tag set is intended to hold approximately that number
+ of tags. */
+census_tag_set *census_tag_set_create(size_t size_hint);
+
+/* Add a new tag key/value to an existing tag set; if the tag key already exists
+ in the tag set, then its value is overwritten with the new one. Can also be
+ used to delete a tag, by specifying a NULL value. If key is NULL, returns
+ the number of tags in the tag set.
+ Return values:
+ -1: invalid length key or value
+ non-negative value: the number of tags in the tag set. */
+int census_tag_set_add(census_tag_set *tags, const char *key,
+ const char *value);
+
+/* Destroys a tag set. This function must be called to prevent memory leaks.
+ Once called, the tag set cannot be used again. */
+void census_tag_set_destroy(census_tag_set *tags);
+
+/* Get a contexts tag set. */
+census_tag_set *census_context_tag_set(census_context *context);
+
+/* A read-only representation of a tag for use by census clients. */
+typedef struct {
+ size_t key_len; /* Number of bytes in tag key. */
+ const char *key; /* A pointer to the tag key. May not be null-terminated. */
+ size_t value_len; /* Number of bytes in tag value. */
+ const char *value; /* Pointer to the tag value. May not be null-terminated. */
+} census_tag_const;
+
+/* Used to iterate through a tag sets contents. */
+typedef struct census_tag_set_iterator census_tag_set_iterator;
+
+/* Open a tag set for iteration. The tag set must not be modified while
+ iteration is ongoing. Returns an iterator for use in following functions. */
+census_tag_set_iterator *census_tag_set_open(census_tag_set *tags);
+
+/* Get the next tag in the tag set, by writing into the 'tag' argument. Returns
+ 1 if there is a "next" tag, 0 if there are no more tags. */
+int census_tag_set_next(census_tag_set_iterator *it, census_tag_const *tag);
+
+/* Close an iterator opened by census_tag_set_open(). The iterator will be
+ invalidated, and should not be used once close is called. */
+void census_tag_set_close(census_tag_set_iterator *it);
+
/* A census statistic to be recorded comprises two parts: an ID for the
* particular statistic and the value to be recorded against it. */
typedef struct {
diff --git a/include/grpc/compression.h b/include/grpc/compression.h
index 82e326fe0e..2f3e14bfa0 100644
--- a/include/grpc/compression.h
+++ b/include/grpc/compression.h
@@ -75,7 +75,9 @@ int grpc_compression_algorithm_parse(const char *name, size_t name_length,
grpc_compression_algorithm *algorithm);
/** Updates \a name with the encoding name corresponding to a valid \a
- * algorithm. Returns 1 upon success, 0 otherwise. */
+ * algorithm. Note that the string returned through \a name upon success is
+ * statically allocated and shouldn't be freed. Returns 1 upon success, 0
+ * otherwise. */
int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm,
char **name);
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index bf340e81ca..7869e9272e 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -181,7 +181,9 @@ typedef enum grpc_call_error {
GRPC_CALL_ERROR_INVALID_MESSAGE,
/** completion queue for notification has not been registered with the
server */
- GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE
+ GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE,
+ /** this batch of operations leads to more operations than allowed */
+ GRPC_CALL_ERROR_BATCH_TOO_BIG
} grpc_call_error;
/* Write Flags: */
@@ -200,13 +202,14 @@ typedef struct grpc_metadata {
const char *key;
const char *value;
size_t value_length;
+ gpr_uint32 flags;
/** The following fields are reserved for grpc internal use.
There is no need to initialize them, and they will be set to garbage
during
calls to grpc. */
struct {
- void *obfuscated[3];
+ void *obfuscated[4];
} internal_data;
} grpc_metadata;
@@ -249,6 +252,7 @@ typedef struct {
char *host;
size_t host_capacity;
gpr_timespec deadline;
+ void *reserved;
} grpc_call_details;
void grpc_call_details_init(grpc_call_details *details);
@@ -256,31 +260,44 @@ void grpc_call_details_destroy(grpc_call_details *details);
typedef enum {
/** Send initial metadata: one and only one instance MUST be sent for each
- call, unless the call was cancelled - in which case this can be skipped */
+ call, unless the call was cancelled - in which case this can be skipped.
+ This op completes after all bytes of metadata have been accepted by
+ outgoing flow control. */
GRPC_OP_SEND_INITIAL_METADATA = 0,
- /** Send a message: 0 or more of these operations can occur for each call */
+ /** Send a message: 0 or more of these operations can occur for each call.
+ This op completes after all bytes for the message have been accepted by
+ outgoing flow control. */
GRPC_OP_SEND_MESSAGE,
/** Send a close from the client: one and only one instance MUST be sent from
the client, unless the call was cancelled - in which case this can be
- skipped */
+ skipped.
+ This op completes after all bytes for the call (including the close)
+ have passed outgoing flow control. */
GRPC_OP_SEND_CLOSE_FROM_CLIENT,
/** Send status from the server: one and only one instance MUST be sent from
the server unless the call was cancelled - in which case this can be
- skipped */
+ skipped.
+ This op completes after all bytes for the call (including the status)
+ have passed outgoing flow control. */
GRPC_OP_SEND_STATUS_FROM_SERVER,
/** Receive initial metadata: one and only one MUST be made on the client,
- must not be made on the server */
+ must not be made on the server.
+ This op completes after all initial metadata has been read from the
+ peer. */
GRPC_OP_RECV_INITIAL_METADATA,
- /** Receive a message: 0 or more of these operations can occur for each call
- */
+ /** Receive a message: 0 or more of these operations can occur for each call.
+ This op completes after all bytes of the received message have been
+ read, or after a half-close has been received on this call. */
GRPC_OP_RECV_MESSAGE,
/** Receive status on the client: one and only one must be made on the client.
- This operation always succeeds, meaning ops paired with this operation
- will also appear to succeed, even though they may not have. In that case
- the status will indicate some failure. */
+ This operation always succeeds, meaning ops paired with this operation
+ will also appear to succeed, even though they may not have. In that case
+ the status will indicate some failure.
+ This op completes after all activity on the call has completed. */
GRPC_OP_RECV_STATUS_ON_CLIENT,
/** Receive close on the server: one and only one must be made on the
- server */
+ server.
+ This op completes after the close has been received by the server. */
GRPC_OP_RECV_CLOSE_ON_SERVER
} grpc_op_type;
@@ -291,7 +308,13 @@ typedef struct grpc_op {
grpc_op_type op;
/** Write flags bitset for grpc_begin_messages */
gpr_uint32 flags;
+ /** Reserved for future usage */
+ void *reserved;
union {
+ /** Reserved for future usage */
+ struct {
+ void *reserved[8];
+ } reserved;
struct {
size_t count;
grpc_metadata *metadata;
@@ -353,6 +376,16 @@ typedef struct grpc_op {
} data;
} grpc_op;
+/** Registers a plugin to be initialized and destroyed with the library.
+
+ The \a init and \a destroy functions will be invoked as part of
+ \a grpc_init() and \a grpc_shutdown(), respectively.
+ Note that these functions can be invoked an arbitrary number of times
+ (and hence so will \a init and \a destroy).
+ It is safe to pass NULL to either argument. Plugins are destroyed in
+ the reverse order they were initialized. */
+void grpc_register_plugin(void (*init)(void), void (*destroy)(void));
+
/* Propagation bits: this can be bitwise or-ed to form propagation_mask for
* grpc_call */
/** Propagate deadline */
@@ -365,8 +398,8 @@ typedef struct grpc_op {
/* Default propagation mask: clients of the core API are encouraged to encode
deltas from this in their implementations... ie write:
- GRPC_PROPAGATE_DEFAULTS & ~GRPC_PROPAGATE_DEADLINE to disable deadline
- propagation. Doing so gives flexibility in the future to define new
+ GRPC_PROPAGATE_DEFAULTS & ~GRPC_PROPAGATE_DEADLINE to disable deadline
+ propagation. Doing so gives flexibility in the future to define new
propagation types that are default inherited or not. */
#define GRPC_PROPAGATE_DEFAULTS \
((gpr_uint32)(( \
@@ -393,7 +426,7 @@ void grpc_shutdown(void);
const char *grpc_version_string(void);
/** Create a completion queue */
-grpc_completion_queue *grpc_completion_queue_create(void);
+grpc_completion_queue *grpc_completion_queue_create(void *reserved);
/** Blocks until an event is available, the completion queue is being shut down,
or deadline is reached.
@@ -404,7 +437,7 @@ grpc_completion_queue *grpc_completion_queue_create(void);
Callers must not call grpc_completion_queue_next and
grpc_completion_queue_pluck simultaneously on the same completion queue. */
grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
- gpr_timespec deadline);
+ gpr_timespec deadline, void *reserved);
/** Blocks until an event with tag 'tag' is available, the completion queue is
being shutdown or deadline is reached.
@@ -413,12 +446,12 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
otherwise a grpc_event describing the event that occurred.
Callers must not call grpc_completion_queue_next and
- grpc_completion_queue_pluck simultaneously on the same completion queue.
-
+ grpc_completion_queue_pluck simultaneously on the same completion queue.
+
Completion queues support a maximum of GRPC_MAX_COMPLETION_QUEUE_PLUCKERS
concurrently executing plucks at any time. */
grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
- gpr_timespec deadline);
+ gpr_timespec deadline, void *reserved);
/** Maximum number of outstanding grpc_completion_queue_pluck executions per
completion queue */
@@ -454,24 +487,24 @@ void grpc_channel_watch_connectivity_state(
completions are sent to 'completion_queue'. 'method' and 'host' need only
live through the invocation of this function.
If parent_call is non-NULL, it must be a server-side call. It will be used
- to propagate properties from the server call to this new client call.
+ to propagate properties from the server call to this new client call.
*/
grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_call *parent_call,
gpr_uint32 propagation_mask,
grpc_completion_queue *completion_queue,
const char *method, const char *host,
- gpr_timespec deadline);
+ gpr_timespec deadline, void *reserved);
/** Pre-register a method/host pair on a channel. */
void *grpc_channel_register_call(grpc_channel *channel, const char *method,
- const char *host);
+ const char *host, void *reserved);
/** Create a call given a handle returned from grpc_channel_register_call */
grpc_call *grpc_channel_create_registered_call(
grpc_channel *channel, grpc_call *parent_call, gpr_uint32 propagation_mask,
grpc_completion_queue *completion_queue, void *registered_call_handle,
- gpr_timespec deadline);
+ gpr_timespec deadline, void *reserved);
/** Start a batch of operations defined in the array ops; when complete, post a
completion of type 'tag' to the completion queue bound to the call.
@@ -485,7 +518,7 @@ grpc_call *grpc_channel_create_registered_call(
containing just send operations independently from batches containing just
receive operations. */
grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
- size_t nops, void *tag);
+ size_t nops, void *tag, void *reserved);
/** Returns a newly allocated string representing the endpoint to which this
call is communicating with. The string is in the uri format accepted by
@@ -517,10 +550,13 @@ char *grpc_channel_get_target(grpc_channel *channel);
more on this. The data in 'args' need only live through the invocation of
this function. */
grpc_channel *grpc_insecure_channel_create(const char *target,
- const grpc_channel_args *args);
+ const grpc_channel_args *args,
+ void *reserved);
/** Create a lame client: this client fails every operation attempted on it. */
-grpc_channel *grpc_lame_client_channel_create(const char *target);
+grpc_channel *grpc_lame_client_channel_create(const char *target,
+ grpc_status_code error_code,
+ const char *error_message);
/** Close and destroy a grpc channel */
void grpc_channel_destroy(grpc_channel *channel);
@@ -536,7 +572,7 @@ void grpc_channel_destroy(grpc_channel *channel);
THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status
are thread-safe, and can be called at any point before grpc_call_destroy
is called.*/
-grpc_call_error grpc_call_cancel(grpc_call *call);
+grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
/** Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread.
@@ -546,7 +582,8 @@ grpc_call_error grpc_call_cancel(grpc_call *call);
remote endpoint. */
grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
grpc_status_code status,
- const char *description);
+ const char *description,
+ void *reserved);
/** Destroy a call.
THREAD SAFETY: grpc_call_destroy is thread-compatible */
@@ -585,14 +622,15 @@ grpc_call_error grpc_server_request_registered_call(
be specified with args. If no additional configuration is needed, args can
be NULL. See grpc_channel_args for more. The data in 'args' need only live
through the invocation of this function. */
-grpc_server *grpc_server_create(const grpc_channel_args *args);
+grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved);
/** Register a completion queue with the server. Must be done for any
notification completion queue that is passed to grpc_server_request_*_call
and to grpc_server_shutdown_and_notify. Must be performed prior to
grpc_server_start. */
void grpc_server_register_completion_queue(grpc_server *server,
- grpc_completion_queue *cq);
+ grpc_completion_queue *cq,
+ void *reserved);
/** Add a HTTP2 over plaintext over tcp listener.
Returns bound port number on success, 0 on failure.
diff --git a/include/grpc/support/cancellable_platform.h b/include/grpc/grpc_zookeeper.h
index e8e4b84e2f..2b195c18bf 100644
--- a/include/grpc/support/cancellable_platform.h
+++ b/include/grpc/grpc_zookeeper.h
@@ -31,26 +31,29 @@
*
*/
-#ifndef GRPC_SUPPORT_CANCELLABLE_PLATFORM_H
-#define GRPC_SUPPORT_CANCELLABLE_PLATFORM_H
+/** Support zookeeper as alternative name system in addition to DNS
+ * Zookeeper name in gRPC is represented as a URI:
+ * zookeeper://host:port/path/service/instance
+ *
+ * Where zookeeper is the name system scheme
+ * host:port is the address of a zookeeper server
+ * /path/service/instance is the zookeeper name to be resolved
+ *
+ * Refer doc/naming.md for more details
+ */
+
+#ifndef GRPC_GRPC_ZOOKEEPER_H
+#define GRPC_GRPC_ZOOKEEPER_H
-#include <grpc/support/atm.h>
-#include <grpc/support/sync.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
-struct gpr_cancellable_list_ {
- /* a doubly-linked list on cancellable's waiters queue */
- struct gpr_cancellable_list_ *next;
- struct gpr_cancellable_list_ *prev;
- /* The following two fields are arguments to gpr_cv_cancellable_wait() */
- gpr_mu *mu;
- gpr_cv *cv;
-};
+/** Register zookeeper name resolver in grpc */
+void grpc_zookeeper_register();
-/* Internal definition of gpr_cancellable. */
-typedef struct {
- gpr_mu mu; /* protects waiters and modifications to cancelled */
- gpr_atm cancelled;
- struct gpr_cancellable_list_ waiters;
-} gpr_cancellable;
+#ifdef __cplusplus
+}
+#endif
-#endif /* GRPC_SUPPORT_CANCELLABLE_PLATFORM_H */
+#endif /* GRPC_GRPC_ZOOKEEPER_H */
diff --git a/include/grpc/status.h b/include/grpc/status.h
index 456b9006e7..65ce410227 100644
--- a/include/grpc/status.h
+++ b/include/grpc/status.h
@@ -160,4 +160,4 @@ typedef enum {
}
#endif
-#endif /* GRPC_STATUS_H */
+#endif /* GRPC_STATUS_H */
diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h
index 509870f3e3..9d4e743da7 100644
--- a/include/grpc/support/alloc.h
+++ b/include/grpc/support/alloc.h
@@ -55,4 +55,4 @@ void gpr_free_aligned(void *ptr);
}
#endif
-#endif /* GRPC_SUPPORT_ALLOC_H */
+#endif /* GRPC_SUPPORT_ALLOC_H */
diff --git a/include/grpc/support/atm.h b/include/grpc/support/atm.h
index ba8d7f579e..3f88e2e1a5 100644
--- a/include/grpc/support/atm.h
+++ b/include/grpc/support/atm.h
@@ -89,4 +89,4 @@
#error could not determine platform for atm
#endif
-#endif /* GRPC_SUPPORT_ATM_H */
+#endif /* GRPC_SUPPORT_ATM_H */
diff --git a/include/grpc/support/atm_gcc_atomic.h b/include/grpc/support/atm_gcc_atomic.h
index a2c8386028..104e1d51df 100644
--- a/include/grpc/support/atm_gcc_atomic.h
+++ b/include/grpc/support/atm_gcc_atomic.h
@@ -69,4 +69,4 @@ static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
__ATOMIC_RELAXED);
}
-#endif /* GRPC_SUPPORT_ATM_GCC_ATOMIC_H */
+#endif /* GRPC_SUPPORT_ATM_GCC_ATOMIC_H */
diff --git a/include/grpc/support/atm_gcc_sync.h b/include/grpc/support/atm_gcc_sync.h
index 38b5a9eec2..241ae76c91 100644
--- a/include/grpc/support/atm_gcc_sync.h
+++ b/include/grpc/support/atm_gcc_sync.h
@@ -84,4 +84,4 @@ static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
#define gpr_atm_acq_cas(p, o, n) (__sync_bool_compare_and_swap((p), (o), (n)))
#define gpr_atm_rel_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n))
-#endif /* GRPC_SUPPORT_ATM_GCC_SYNC_H */
+#endif /* GRPC_SUPPORT_ATM_GCC_SYNC_H */
diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h
index 694528a9ba..cc016e5cdf 100644
--- a/include/grpc/support/atm_win32.h
+++ b/include/grpc/support/atm_win32.h
@@ -66,31 +66,31 @@ static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
/* InterlockedCompareExchangePointerNoFence() not available on vista or
windows7 */
#ifdef GPR_ARCH_64
- return o == (gpr_atm)InterlockedCompareExchangeAcquire64((volatile LONGLONG *) p,
- (LONGLONG) n, (LONGLONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire64(
+ (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *) p,
- (LONG) n, (LONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p,
+ (LONG)n, (LONG)o);
#endif
}
static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
#ifdef GPR_ARCH_64
- return o == (gpr_atm)InterlockedCompareExchangeAcquire64((volatile LONGLONG *) p,
- (LONGLONG) n, (LONGLONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire64(
+ (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *) p,
- (LONG) n, (LONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p,
+ (LONG)n, (LONG)o);
#endif
}
static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
#ifdef GPR_ARCH_64
- return o == (gpr_atm)InterlockedCompareExchangeRelease64((volatile LONGLONG *) p,
- (LONGLONG) n, (LONGLONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeRelease64(
+ (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o);
#else
- return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG *) p,
- (LONG) n, (LONG) o);
+ return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG *)p,
+ (LONG)n, (LONG)o);
#endif
}
@@ -110,17 +110,16 @@ static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm *p, gpr_atm delta) {
#ifdef GPR_ARCH_64
do {
old = *p;
- } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *) p,
- (LONGLONG) old + delta,
- (LONGLONG) old));
+ } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *)p,
+ (LONGLONG)old + delta,
+ (LONGLONG)old));
#else
do {
old = *p;
- } while (old != (gpr_atm)InterlockedCompareExchange((volatile LONG *) p,
- (LONG) old + delta,
- (LONG) old));
+ } while (old != (gpr_atm)InterlockedCompareExchange(
+ (volatile LONG *)p, (LONG)old + delta, (LONG)old));
#endif
return old;
}
-#endif /* GRPC_SUPPORT_ATM_WIN32_H */
+#endif /* GRPC_SUPPORT_ATM_WIN32_H */
diff --git a/include/grpc/support/cmdline.h b/include/grpc/support/cmdline.h
index e5a266666e..028dac2955 100644
--- a/include/grpc/support/cmdline.h
+++ b/include/grpc/support/cmdline.h
@@ -94,4 +94,4 @@ char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0);
}
#endif
-#endif /* GRPC_SUPPORT_CMDLINE_H */
+#endif /* GRPC_SUPPORT_CMDLINE_H */
diff --git a/include/grpc/support/cpu.h b/include/grpc/support/cpu.h
index 2b2a56168a..7d8af59911 100644
--- a/include/grpc/support/cpu.h
+++ b/include/grpc/support/cpu.h
@@ -54,4 +54,4 @@ unsigned gpr_cpu_current_cpu(void);
} // extern "C"
#endif
-#endif /* GRPC_SUPPORT_CPU_H */
+#endif /* GRPC_SUPPORT_CPU_H */
diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h
index 64d08f0bf1..2fd1084208 100644
--- a/include/grpc/support/histogram.h
+++ b/include/grpc/support/histogram.h
@@ -73,4 +73,4 @@ void gpr_histogram_merge_contents(gpr_histogram *histogram,
}
#endif
-#endif /* GRPC_SUPPORT_HISTOGRAM_H */
+#endif /* GRPC_SUPPORT_HISTOGRAM_H */
diff --git a/include/grpc/support/host_port.h b/include/grpc/support/host_port.h
index 30267ab1df..375d1774e6 100644
--- a/include/grpc/support/host_port.h
+++ b/include/grpc/support/host_port.h
@@ -61,4 +61,4 @@ int gpr_split_host_port(const char *name, char **host, char **port);
}
#endif
-#endif /* GRPC_SUPPORT_HOST_PORT_H */
+#endif /* GRPC_SUPPORT_HOST_PORT_H */
diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h
index aad4f235d2..59db4ba1dd 100644
--- a/include/grpc/support/log.h
+++ b/include/grpc/support/log.h
@@ -105,4 +105,4 @@ void gpr_set_log_function(gpr_log_func func);
}
#endif
-#endif /* GRPC_SUPPORT_LOG_H */
+#endif /* GRPC_SUPPORT_LOG_H */
diff --git a/include/grpc/support/log_win32.h b/include/grpc/support/log_win32.h
index 595a81a5af..ea6b16dd77 100644
--- a/include/grpc/support/log_win32.h
+++ b/include/grpc/support/log_win32.h
@@ -48,4 +48,4 @@ char *gpr_format_message(DWORD messageid);
}
#endif
-#endif /* GRPC_SUPPORT_LOG_WIN32_H */
+#endif /* GRPC_SUPPORT_LOG_WIN32_H */
diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h
index 57fed18cf6..d09815557e 100644
--- a/include/grpc/support/port_platform.h
+++ b/include/grpc/support/port_platform.h
@@ -64,7 +64,8 @@
#undef GRPC_NOMINMAX_WAS_NOT_DEFINED
#undef NOMINMAX
#endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
-#endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) */
+#endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || \
+ defined(WIN32) */
/* Override this file with one for your platform if you need to redefine
things. */
@@ -173,6 +174,8 @@
#endif /* _LP64 */
#elif defined(__APPLE__)
#include <TargetConditionals.h>
+/* Provides IPV6_RECVPKTINFO */
+#define __APPLE_USE_RFC_3542
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h
index ec6c117afe..3abb1b7ca1 100644
--- a/include/grpc/support/slice.h
+++ b/include/grpc/support/slice.h
@@ -96,7 +96,7 @@ typedef struct gpr_slice {
#define GPR_SLICE_LENGTH(slice) \
((slice).refcount ? (slice).data.refcounted.length \
: (slice).data.inlined.length)
-#define GPR_SLICE_SET_LENGTH(slice, newlen) \
+#define GPR_SLICE_SET_LENGTH(slice, newlen) \
((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
: ((slice).data.inlined.length = (gpr_uint8)(newlen)))
#define GPR_SLICE_END_PTR(slice) \
diff --git a/include/grpc/support/string_util.h b/include/grpc/support/string_util.h
index 515709447b..109f9ffdf7 100644
--- a/include/grpc/support/string_util.h
+++ b/include/grpc/support/string_util.h
@@ -58,4 +58,4 @@ int gpr_asprintf(char **strp, const char *format, ...);
}
#endif
-#endif /* GRPC_SUPPORT_STRING_UTIL_H */
+#endif /* GRPC_SUPPORT_STRING_UTIL_H */
diff --git a/include/grpc/support/subprocess.h b/include/grpc/support/subprocess.h
index c884e5ef5e..654623fd09 100644
--- a/include/grpc/support/subprocess.h
+++ b/include/grpc/support/subprocess.h
@@ -36,7 +36,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif
typedef struct gpr_subprocess gpr_subprocess;
diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h
index 1cdde1d2d0..172aea0217 100644
--- a/include/grpc/support/sync.h
+++ b/include/grpc/support/sync.h
@@ -65,7 +65,6 @@
#endif
#include <grpc/support/time.h> /* for gpr_timespec */
-#include <grpc/support/cancellable_platform.h>
#ifdef __cplusplus
extern "C" {
@@ -121,11 +120,6 @@ void gpr_cv_destroy(gpr_cv *cv);
holds an exclusive lock on *mu. */
int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline);
-/* Behave like gpr_cv_wait(cv, mu, abs_deadline), except behave as though
- the deadline has expired if *c is cancelled. */
-int gpr_cv_cancellable_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline,
- gpr_cancellable *c);
-
/* If any threads are waiting on *cv, wake at least one.
Clients may treat this as an optimization of gpr_cv_broadcast()
for use in the case where waking more than one waiter is not useful.
@@ -135,28 +129,6 @@ void gpr_cv_signal(gpr_cv *cv);
/* Wake all threads waiting on *cv. Requires: *cv initialized. */
void gpr_cv_broadcast(gpr_cv *cv);
-/* --- Cancellation ---
- A gpr_cancellable can be used with gpr_cv_cancellable_wait()
- or gpr_event_cancellable_wait() cancel pending waits. */
-
-/* Initialize *c. */
-void gpr_cancellable_init(gpr_cancellable *c);
-
-/* Cause *c no longer to be initialized, freeing any memory in use. Requires:
- *c initialized; no other concurrent operation on *c. */
-void gpr_cancellable_destroy(gpr_cancellable *c);
-
-/* Return non-zero iff *c has been cancelled. Requires *c initialized.
- This call is faster than acquiring a mutex on most platforms. */
-int gpr_cancellable_is_cancelled(gpr_cancellable *c);
-
-/* Cancel *c. If *c was not previously cancelled, cause
- gpr_cancellable_init() to return non-zero, and outstanding and future
- calls to gpr_cv_cancellable_wait() and gpr_event_cancellable_wait() to
- return immediately indicating a timeout has occurred; otherwise do nothing.
- Requires *c initialized.*/
-void gpr_cancellable_cancel(gpr_cancellable *c);
-
/* --- One-time initialization ---
gpr_once must be declared with static storage class, and initialized with
@@ -199,11 +171,6 @@ void *gpr_event_get(gpr_event *ev);
on most platforms. */
void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline);
-/* Behave like gpr_event_wait(ev, abs_deadline), except behave as though
- the deadline has expired if *c is cancelled. */
-void *gpr_event_cancellable_wait(gpr_event *ev, gpr_timespec abs_deadline,
- gpr_cancellable *c);
-
/* --- Reference counting ---
These calls act on the type gpr_refcount. It requires no destruction. */
@@ -345,4 +312,4 @@ gpr_intptr gpr_stats_read(const gpr_stats_counter *c);
}
#endif
-#endif /* GRPC_SUPPORT_SYNC_H */
+#endif /* GRPC_SUPPORT_SYNC_H */
diff --git a/include/grpc/support/sync_generic.h b/include/grpc/support/sync_generic.h
index bbd1b3ea2e..fd55e02ea8 100644
--- a/include/grpc/support/sync_generic.h
+++ b/include/grpc/support/sync_generic.h
@@ -38,24 +38,18 @@
#include <grpc/support/atm.h>
/* gpr_event */
-typedef struct {
- gpr_atm state;
-} gpr_event;
+typedef struct { gpr_atm state; } gpr_event;
#define GPR_EVENT_INIT \
{ 0 }
/* gpr_refcount */
-typedef struct {
- gpr_atm count;
-} gpr_refcount;
+typedef struct { gpr_atm count; } gpr_refcount;
/* gpr_stats_counter */
-typedef struct {
- gpr_atm value;
-} gpr_stats_counter;
+typedef struct { gpr_atm value; } gpr_stats_counter;
#define GPR_STATS_INIT \
{ 0 }
-#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */
+#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */
diff --git a/include/grpc/support/sync_posix.h b/include/grpc/support/sync_posix.h
index 762d9ebe3c..81ffa25900 100644
--- a/include/grpc/support/sync_posix.h
+++ b/include/grpc/support/sync_posix.h
@@ -44,4 +44,4 @@ typedef pthread_once_t gpr_once;
#define GPR_ONCE_INIT PTHREAD_ONCE_INIT
-#endif /* GRPC_SUPPORT_SYNC_POSIX_H */
+#endif /* GRPC_SUPPORT_SYNC_POSIX_H */
diff --git a/include/grpc/support/sync_win32.h b/include/grpc/support/sync_win32.h
index 66b9af9074..8ddbeaab97 100644
--- a/include/grpc/support/sync_win32.h
+++ b/include/grpc/support/sync_win32.h
@@ -46,4 +46,4 @@ typedef CONDITION_VARIABLE gpr_cv;
typedef INIT_ONCE gpr_once;
#define GPR_ONCE_INIT INIT_ONCE_STATIC_INIT
-#endif /* GRPC_SUPPORT_SYNC_WIN32_H */
+#endif /* GRPC_SUPPORT_SYNC_WIN32_H */
diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h
index 8126992d6b..d3265f25bd 100644
--- a/include/grpc/support/thd.h
+++ b/include/grpc/support/thd.h
@@ -88,4 +88,4 @@ void gpr_thd_join(gpr_thd_id t);
}
#endif
-#endif /* GRPC_SUPPORT_THD_H */
+#endif /* GRPC_SUPPORT_THD_H */
diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h
index be59c37956..4ef9c76459 100644
--- a/include/grpc/support/time.h
+++ b/include/grpc/support/time.h
@@ -84,7 +84,8 @@ void gpr_time_init(void);
gpr_timespec gpr_now(gpr_clock_type clock);
/* Convert a timespec from one clock to another */
-gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock);
+gpr_timespec gpr_convert_clock_type(gpr_timespec t,
+ gpr_clock_type target_clock);
/* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
respectively. */
diff --git a/include/grpc/support/tls.h b/include/grpc/support/tls.h
index 156280e47d..a4ebac56fd 100644
--- a/include/grpc/support/tls.h
+++ b/include/grpc/support/tls.h
@@ -47,7 +47,7 @@
GPR_TLS_DECL(foo);
Thread locals always have static scope.
- Initializing a thread local (must be done at library initialization
+ Initializing a thread local (must be done at library initialization
time):
gpr_tls_init(&foo);
@@ -58,7 +58,7 @@
gpr_tls_set(&foo, new_value);
Accessing a thread local:
- current_value = gpr_tls_get(&foo, value);
+ current_value = gpr_tls_get(&foo, value);
ALL functions here may be implemented as macros. */
diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h
index a078b104ea..1a02fb22d7 100644
--- a/include/grpc/support/tls_gcc.h
+++ b/include/grpc/support/tls_gcc.h
@@ -42,10 +42,14 @@ struct gpr_gcc_thread_local {
};
#define GPR_TLS_DECL(name) \
- static __thread struct gpr_gcc_thread_local name = {0}
+ static __thread struct gpr_gcc_thread_local name = {0}
-#define gpr_tls_init(tls) do {} while (0)
-#define gpr_tls_destroy(tls) do {} while (0)
+#define gpr_tls_init(tls) \
+ do { \
+ } while (0)
+#define gpr_tls_destroy(tls) \
+ do { \
+ } while (0)
#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value))
#define gpr_tls_get(tls) ((tls)->value)
diff --git a/include/grpc/support/tls_msvc.h b/include/grpc/support/tls_msvc.h
index 526aeeacdf..9997f8e4b0 100644
--- a/include/grpc/support/tls_msvc.h
+++ b/include/grpc/support/tls_msvc.h
@@ -42,10 +42,14 @@ struct gpr_msvc_thread_local {
};
#define GPR_TLS_DECL(name) \
- static __declspec(thread) struct gpr_msvc_thread_local name = {0}
+ static __declspec(thread) struct gpr_msvc_thread_local name = {0}
-#define gpr_tls_init(tls) do {} while (0)
-#define gpr_tls_destroy(tls) do {} while (0)
+#define gpr_tls_init(tls) \
+ do { \
+ } while (0)
+#define gpr_tls_destroy(tls) \
+ do { \
+ } while (0)
#define gpr_tls_set(tls, new_value) (((tls)->value) = (new_value))
#define gpr_tls_get(tls) ((tls)->value)
diff --git a/include/grpc/support/useful.h b/include/grpc/support/useful.h
index 3842611590..9f08d788c0 100644
--- a/include/grpc/support/useful.h
+++ b/include/grpc/support/useful.h
@@ -46,10 +46,10 @@
#define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array)))
#define GPR_SWAP(type, a, b) \
- do { \
- type x = a; \
- a = b; \
- b = x; \
+ do { \
+ type x = a; \
+ a = b; \
+ b = x; \
} while (0)
/** Set the \a n-th bit of \a i (a mutable pointer). */
@@ -72,4 +72,4 @@
0x0f0f0f0f) % \
255)
-#endif /* GRPC_SUPPORT_USEFUL_H */
+#endif /* GRPC_SUPPORT_USEFUL_H */