diff options
author | Craig Tiller <ctiller@google.com> | 2015-08-17 13:23:14 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-08-17 13:23:14 -0700 |
commit | 8f7bff7d48129e577f972815afcc9f32c78d258b (patch) | |
tree | c2f278fdefc6348a0ba2ba413b13e613115fdc8c /include | |
parent | d067c263b250657891de4ad96ae51249435c6066 (diff) | |
parent | 2194cd8fd4d53a3333fbd0e7bc938e22210d23d2 (diff) |
Merge github.com:grpc/grpc into y12kdm3
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/client_context.h | 4 | ||||
-rw-r--r-- | include/grpc++/completion_queue.h | 2 | ||||
-rw-r--r-- | include/grpc++/impl/call.h | 35 | ||||
-rw-r--r-- | include/grpc++/impl/rpc_service_method.h | 21 | ||||
-rw-r--r-- | include/grpc++/server.h | 24 | ||||
-rw-r--r-- | include/grpc++/server_builder.h | 17 | ||||
-rw-r--r-- | include/grpc++/server_context.h | 2 | ||||
-rw-r--r-- | include/grpc++/stream.h | 11 | ||||
-rw-r--r-- | include/grpc/byte_buffer.h | 4 | ||||
-rw-r--r-- | include/grpc/census.h | 55 | ||||
-rw-r--r-- | include/grpc/grpc.h | 65 | ||||
-rw-r--r-- | include/grpc/grpc_zookeeper.h (renamed from include/grpc/support/cancellable_platform.h) | 41 | ||||
-rw-r--r-- | include/grpc/support/port_platform.h | 2 | ||||
-rw-r--r-- | include/grpc/support/sync.h | 33 |
14 files changed, 201 insertions, 115 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 34945f3282..d7fafac9b3 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -218,15 +218,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++/impl/call.h b/include/grpc++/impl/call.h index 1fa4490779..35338a413e 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) { @@ -545,8 +541,7 @@ class CallOpSet : public CallOpSetInterface, template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>, class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>, class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>> -class SneakyCallOpSet GRPC_FINAL - : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> { +class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> { public: bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { typedef CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> Base; diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 3cfbef7806..c02ebec19e 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -208,6 +208,27 @@ class BidiStreamingHandler : public MethodHandler { ServiceType* service_; }; +// Handle unknown method by returning UNIMPLEMENTED error. +class UnknownMethodHandler : public MethodHandler { + public: + template <class T> + static void FillOps(ServerContext* context, T* ops) { + Status status(StatusCode::UNIMPLEMENTED, ""); + if (!context->sent_initial_metadata_) { + ops->SendInitialMetadata(context->initial_metadata_); + context->sent_initial_metadata_ = true; + } + ops->ServerSendStatus(context->trailing_metadata_, status); + } + + void RunHandler(const HandlerParameter& param) GRPC_FINAL { + CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops; + FillOps(param.server_context, &ops); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } +}; + // Server side rpc method class class RpcServiceMethod : public RpcMethod { public: diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 94ee0b6a4a..516266d3a4 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -84,13 +84,14 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { int max_message_size); // 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); // Start the server. - bool Start(); + bool Start(ServerCompletionQueue** cqs, size_t num_cqs); void HandleQueueClosed(); void RunRpc(); @@ -102,7 +103,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { public: BaseAsyncRequest(Server* server, ServerContext* context, ServerAsyncStreamingInterface* stream, - CompletionQueue* call_cq, void* tag); + CompletionQueue* call_cq, void* tag, + bool delete_on_finalize); virtual ~BaseAsyncRequest(); bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; @@ -113,6 +115,7 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { ServerAsyncStreamingInterface* const stream_; CompletionQueue* const call_cq_; void* const tag_; + const bool delete_on_finalize_; grpc_call* call_; grpc_metadata_array initial_metadata_array_; }; @@ -174,12 +177,13 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { Message* const request_; }; - class GenericAsyncRequest GRPC_FINAL : public BaseAsyncRequest { + class GenericAsyncRequest : public BaseAsyncRequest { public: GenericAsyncRequest(Server* server, GenericServerContext* context, ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, - ServerCompletionQueue* notification_cq, void* tag); + ServerCompletionQueue* notification_cq, void* tag, + bool delete_on_finalize); bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; @@ -187,6 +191,10 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { grpc_call_details call_details_; }; + class UnimplementedAsyncRequestContext; + class UnimplementedAsyncRequest; + class UnimplementedAsyncResponse; + template <class Message> void RequestAsyncCall(void* registered_method, ServerContext* context, ServerAsyncStreamingInterface* stream, @@ -211,7 +219,7 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { ServerCompletionQueue* notification_cq, void* tag) { new GenericAsyncRequest(this, context, stream, call_cq, notification_cq, - tag); + tag, true); } const int max_message_size_; @@ -228,6 +236,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 44ee00eec9..8666252d51 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -76,15 +76,14 @@ class ServerBuilder { // The service must exist for the lifetime of the Server instance returned by // BuildAndStart(). // Only matches requests with :authority \a host - void RegisterService(const grpc::string& host, - SynchronousService* service); + void RegisterService(const grpc::string& host, SynchronousService* service); // Register an asynchronous service. // This call does not take ownership of the service or completion queue. // The service and completion queuemust exist for the lifetime of the Server // instance returned by BuildAndStart(). // Only matches requests with :authority \a host - void RegisterAsyncService(const grpc::string& host, + void RegisterAsyncService(const grpc::string& host, AsynchronousService* service); // Set max message size in bytes. @@ -102,8 +101,8 @@ class ServerBuilder { void SetThreadPool(ThreadPoolInterface* thread_pool); // Add a completion queue for handling asynchronous services - // Caller is required to keep this completion queue live until calling - // BuildAndStart() + // Caller is required to keep this completion queue live until + // the server is destroyed. std::unique_ptr<ServerCompletionQueue> AddCompletionQueue(); // Return a running server which is ready for processing rpcs. @@ -117,9 +116,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; @@ -127,7 +127,8 @@ class ServerBuilder { int max_message_size_; 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 4f7fc54ef1..8262dee654 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..4bffaffb40 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); } @@ -764,6 +761,8 @@ class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, } private: + friend class ::grpc::Server; + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } Call call_; 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/grpc.h b/include/grpc/grpc.h index 5915dda2ba..2d53325b77 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -202,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; @@ -251,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); @@ -306,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; @@ -368,6 +376,23 @@ 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)); + +/** Frees the memory used by all the plugin information. + + While grpc_init and grpc_shutdown can be called multiple times, the plugins + won't be unregistered and their memory cleaned up unless you call that + function. Using atexit(grpc_unregister_all_plugins) is a valid method. */ +void grpc_unregister_all_plugins(); + /* Propagation bits: this can be bitwise or-ed to form propagation_mask for * grpc_call */ /** Propagate deadline */ @@ -380,8 +405,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)(( \ @@ -408,7 +433,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. @@ -419,7 +444,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. @@ -428,12 +453,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 */ @@ -469,24 +494,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. @@ -500,7 +525,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 @@ -532,7 +557,8 @@ 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); @@ -551,7 +577,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. @@ -561,7 +587,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 */ @@ -600,14 +627,16 @@ 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/support/port_platform.h b/include/grpc/support/port_platform.h index 57fed18cf6..d5745f9878 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -173,6 +173,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/sync.h b/include/grpc/support/sync.h index 1cdde1d2d0..1dd826a828 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. */ |