grpc_ares_ev_driver.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
21 
23 
24 #include <memory>
25 
26 #include <ares.h>
27 
28 #include "absl/base/thread_annotations.h"
29 
35 
36 namespace grpc_core {
37 
38 /* A wrapped fd that integrates with the grpc iomgr of the current platform.
39  * A GrpcPolledFd knows how to create grpc platform-specific iomgr endpoints
40  * from "ares_socket_t" sockets, and then sign up for readability/writeability
41  * with that poller, and do shutdown and destruction. */
42 class GrpcPolledFd {
43  public:
44  virtual ~GrpcPolledFd() {}
45  /* Called when c-ares library is interested and there's no pending callback */
46  virtual void RegisterForOnReadableLocked(grpc_closure* read_closure)
48  /* Called when c-ares library is interested and there's no pending callback */
49  virtual void RegisterForOnWriteableLocked(grpc_closure* write_closure)
51  /* Indicates if there is data left even after just being read from */
52  virtual bool IsFdStillReadableLocked()
54  /* Called once and only once. Must cause cancellation of any pending
55  * read/write callbacks. */
56  virtual void ShutdownLocked(grpc_error_handle error)
58  /* Get the underlying ares_socket_t that this was created from */
59  virtual ares_socket_t GetWrappedAresSocketLocked()
61  /* A unique name, for logging */
62  virtual const char* GetName() const = 0;
63 };
64 
65 /* A GrpcPolledFdFactory is 1-to-1 with and owned by the
66  * ares event driver. It knows how to create GrpcPolledFd's
67  * for the current platform, and the ares driver uses it for all of
68  * its fd's. */
70  public:
71  virtual ~GrpcPolledFdFactory() {}
72  /* Creates a new wrapped fd for the current platform */
73  virtual GrpcPolledFd* NewGrpcPolledFdLocked(
74  ares_socket_t as, grpc_pollset_set* driver_pollset_set)
76  /* Optionally configures the ares channel after creation */
77  virtual void ConfigureAresChannelLocked(ares_channel channel)
79 };
80 
81 /* Creates a new polled fd factory.
82  * Note that even though ownership of mu is not transferred, the mu
83  * parameter is guaranteed to be alive for the the whole lifetime of
84  * the resulting GrpcPolledFdFactory as well as any GrpcPolledFd
85  * returned by the factory. */
86 std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Mutex* mu);
87 
88 } // namespace grpc_core
89 
90 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H \
91  */
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
ares.h
grpc_core::GrpcPolledFd::GetName
virtual void virtual RegisterForOnReadableLocked(grpc_closure *read_closure) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request void virtual RegisterForOnWriteableLocked(grpc_closure *write_closure) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request bool virtual IsFdStillReadableLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request void virtual ShutdownLocked(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request ares_socket_t virtual const GetWrappedAresSocketLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request char GetName)() const =0
Definition: grpc_ares_ev_driver.h:62
grpc_core
Definition: call_metric_recorder.h:31
grpc_pollset_set
struct grpc_pollset_set grpc_pollset_set
Definition: iomgr_fwd.h:23
error
grpc_error_handle error
Definition: retry_filter.cc:499
closure.h
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
mu
Mutex mu
Definition: server_config_selector_filter.cc:74
grpc_ares_wrapper.h
ABSL_EXCLUSIVE_LOCKS_REQUIRED
#define ABSL_EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: abseil-cpp/absl/base/thread_annotations.h:145
grpc_ares_request::mu
grpc_core::Mutex mu
Definition: grpc_ares_wrapper.h:59
grpc_core::GrpcPolledFd::~GrpcPolledFd
virtual ~GrpcPolledFd()
Definition: grpc_ares_ev_driver.h:44
error.h
grpc_ares_request
Definition: grpc_ares_wrapper.h:56
ares_channeldata
Definition: ares_private.h:266
google::protobuf.internal::Mutex
WrappedMutex Mutex
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/mutex.h:113
ares_socket_t
int ares_socket_t
Definition: ares.h:229
grpc_core::GrpcPolledFd
Definition: grpc_ares_ev_driver.h:42
grpc_core::GrpcPolledFdFactory
Definition: grpc_ares_ev_driver.h:69
iomgr_fwd.h
grpc_error
Definition: error_internal.h:42
grpc_core::NewGrpcPolledFdFactory
std::unique_ptr< GrpcPolledFdFactory > NewGrpcPolledFdFactory(Mutex *mu)
grpc_closure
Definition: closure.h:56
grpc_core::GrpcPolledFdFactory::~GrpcPolledFdFactory
virtual ~GrpcPolledFdFactory()
Definition: grpc_ares_ev_driver.h:71
sync.h
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:47