channel_ping.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
22 #include <grpc/support/alloc.h>
23 #include <grpc/support/log.h>
24 
35 
36 struct ping_result {
38  void* tag;
41 };
42 static void ping_destroy(void* arg, grpc_cq_completion* /*storage*/) {
43  gpr_free(arg);
44 }
45 
46 static void ping_done(void* arg, grpc_error_handle error) {
47  ping_result* pr = static_cast<ping_result*>(arg);
49  &pr->completion_storage);
50 }
51 
53  void* tag, void* reserved) {
54  GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
55  (channel, cq, tag, reserved));
57  ping_result* pr = static_cast<ping_result*>(gpr_malloc(sizeof(*pr)));
58  grpc_channel_element* top_elem =
61  GPR_ASSERT(reserved == nullptr);
62  pr->tag = tag;
63  pr->cq = cq;
64  GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
65  op->send_ping.on_ack = &pr->closure;
66  op->bind_pollset = grpc_cq_pollset(cq);
68  top_elem->filter->start_transport_op(top_elem, op);
69 }
GRPC_CLOSURE_INIT
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
Definition: closure.h:115
trace.h
ping_result
Definition: channel_ping.cc:36
log.h
grpc_channel_ping
void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq, void *tag, void *reserved)
Definition: channel_ping.cc:52
channel_fwd.h
grpc_channel_stack_element
grpc_channel_element * grpc_channel_stack_element(grpc_channel_stack *channel_stack, size_t index)
Definition: channel_stack.cc:78
ping_done
static void ping_done(void *arg, grpc_error_handle error)
Definition: channel_ping.cc:46
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
grpc_channel_element
Definition: channel_stack.h:186
error
grpc_error_handle error
Definition: retry_filter.cc:499
ping_result::closure
grpc_closure closure
Definition: channel_ping.cc:37
completion_queue.h
grpc_channel_get_channel_stack
grpc_channel_stack * grpc_channel_get_channel_stack(grpc_channel *channel)
Definition: src/core/lib/surface/channel.h:178
gpr_malloc
GPRAPI void * gpr_malloc(size_t size)
Definition: alloc.cc:29
closure.h
grpc_cq_completion
Definition: src/core/lib/surface/completion_queue.h:43
grpc_cq_end_op
void grpc_cq_end_op(grpc_completion_queue *cq, void *tag, grpc_error_handle error, void(*done)(void *done_arg, grpc_cq_completion *storage), void *done_arg, grpc_cq_completion *storage, bool internal)
Definition: completion_queue.cc:894
ping_result::tag
void * tag
Definition: channel_ping.cc:38
grpc_transport_op
Definition: transport.h:452
grpc_types.h
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
ping_result::cq
grpc_completion_queue * cq
Definition: channel_ping.cc:39
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
channel_stack.h
grpc_channel_element::filter
const grpc_channel_filter * filter
Definition: channel_stack.h:187
grpc_completion_queue
Definition: completion_queue.cc:347
grpc_cq_pollset
grpc_pollset * grpc_cq_pollset(grpc_completion_queue *cq)
Definition: completion_queue.cc:1433
arg
Definition: cmdline.cc:40
grpc_make_transport_op
grpc_transport_op * grpc_make_transport_op(grpc_closure *on_complete)
Definition: transport.cc:205
error.h
grpc_core::ExecCtx
Definition: exec_ctx.h:97
grpc_cq_begin_op
bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag)
Definition: completion_queue.cc:672
GRPC_ERROR_REF
#define GRPC_ERROR_REF(err)
Definition: error.h:261
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
ping_destroy
static void ping_destroy(void *arg, grpc_cq_completion *)
Definition: channel_ping.cc:42
alloc.h
ping_result::completion_storage
grpc_cq_completion completion_storage
Definition: channel_ping.cc:40
arg
struct arg arg
exec_ctx.h
grpc_channel
struct grpc_channel grpc_channel
Definition: grpc_types.h:62
transport.h
api_trace.h
grpc_error
Definition: error_internal.h:42
grpc_channel_filter::start_transport_op
void(* start_transport_op)(grpc_channel_element *elem, grpc_transport_op *op)
Definition: channel_stack.h:131
grpc_closure
Definition: closure.h:56
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
GRPC_API_TRACE
#define GRPC_API_TRACE(fmt, nargs, args)
Definition: api_trace.h:48
channel.h
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52