blob: b45d7299e2cd4a6a3524921846ab6e4399a5e1e7 [file] [log] [blame]
Yuchen Zeng9b5aa632016-07-26 19:09:56 -07001/*
2 *
3 * Copyright 2016, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
Craig Tillerd608cd62017-04-02 16:23:17 -070034#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
35#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
Yuchen Zengb48000c2016-08-09 22:44:23 -070036
Yuchen Zeng9e4c8eb2016-11-18 01:06:57 -080037#include <ares.h>
38
Yuchen Zeng85750b02016-08-08 14:16:34 -070039#include "src/core/lib/iomgr/exec_ctx.h"
40#include "src/core/lib/iomgr/pollset_set.h"
Yuchen Zeng9b5aa632016-07-26 19:09:56 -070041
Yuchen Zeng85750b02016-08-08 14:16:34 -070042typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
43
Yuchen Zeng38f34fb2016-10-11 15:56:33 -070044/* Start \a ev_driver. It will keep working until all IO on its ares_channel is
Yuchen Zengc1893dc2016-09-30 18:49:41 -070045 done, or grpc_ares_ev_driver_destroy() is called. It may notify the callbacks
46 bound to its ares_channel when necessary. */
47void grpc_ares_ev_driver_start(grpc_exec_ctx *exec_ctx,
Yuchen Zenga418ed22016-08-08 17:24:33 -070048 grpc_ares_ev_driver *ev_driver);
Yuchen Zeng00565312016-08-24 16:41:12 -070049
Yuchen Zeng3ae26632016-11-09 15:53:50 -080050/* Returns the ares_channel owned by \a ev_driver. To bind a c-ares query to
51 \a ev_driver, use the ares_channel owned by \a ev_driver as the arg of the
52 query. */
Yuchen Zeng9e4c8eb2016-11-18 01:06:57 -080053ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver);
Yuchen Zeng85750b02016-08-08 14:16:34 -070054
Yuchen Zengc1893dc2016-09-30 18:49:41 -070055/* Creates a new grpc_ares_ev_driver. Returns GRPC_ERROR_NONE if \a ev_driver is
56 created successfully. */
Yuchen Zeng8917aec2016-08-09 18:41:31 -070057grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
58 grpc_pollset_set *pollset_set);
Yuchen Zengc1893dc2016-09-30 18:49:41 -070059
Yuchen Zeng3ae26632016-11-09 15:53:50 -080060/* Destroys \a ev_driver asynchronously. Pending lookups made on \a ev_driver
61 will be cancelled and their on_done callbacks will be invoked with a status
62 of ARES_ECANCELLED. */
Yuchen Zeng117a3002016-11-17 19:43:36 -080063void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver);
Yuchen Zengb48000c2016-08-09 22:44:23 -070064
Yuchen Zeng3b4bed22017-06-04 01:41:15 -070065/* Shutdown all the grpc_fds used by \a ev_driver */
66void grpc_ares_ev_driver_shutdown(grpc_exec_ctx *exec_ctx,
67 grpc_ares_ev_driver *ev_driver);
68
Craig Tiller90d10152017-04-03 07:15:28 -070069#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H \
70 */