visaljs 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/THIRD_PARTY_LICENSES +31 -1
- package/cli.js +962 -68
- package/node/include/js_node.h +11 -1
- package/node/prelude/_http_common.js +29 -0
- package/node/prelude/async_hooks.js +50 -11
- package/node/prelude/child_process.js +31 -4
- package/node/prelude/console.js +311 -143
- package/node/prelude/crypto.js +6 -4
- package/node/prelude/dgram.js +1169 -0
- package/node/prelude/diagnostics_channel.js +3 -1
- package/node/prelude/dns.js +250 -45
- package/node/prelude/dns_promises.js +8 -2
- package/node/prelude/fs_promises.js +9 -1
- package/node/prelude/http.js +395 -86
- package/node/prelude/https.js +13 -4
- package/node/prelude/internal/console_class.js +7 -0
- package/node/prelude/internal/console_global.js +25 -0
- package/node/prelude/internal/crypto/key_encryption.js +217 -0
- package/node/prelude/internal/crypto/keys.js +161 -26
- package/node/prelude/internal/crypto/random.js +24 -0
- package/node/prelude/internal/crypto/util.js +2 -1
- package/node/prelude/internal/crypto_x509.js +161 -0
- package/node/prelude/internal/dns_classes.js +6 -0
- package/node/prelude/internal/dns_resolver.js +371 -0
- package/node/prelude/internal/errors.js +9 -0
- package/node/prelude/internal/events_on.js +82 -37
- package/node/prelude/internal/features.js +8 -4
- package/node/prelude/internal/fs_filehandle.js +10 -4
- package/node/prelude/internal/perf_histogram.js +1 -1
- package/node/prelude/internal/process_more.js +32 -17
- package/node/prelude/internal/process_signals.js +8 -2
- package/node/prelude/internal/punycode.ts +163 -0
- package/node/prelude/internal/readline.js +648 -274
- package/node/prelude/internal/readline_editor.js +1240 -0
- package/node/prelude/internal/string_width.js +43 -0
- package/node/prelude/internal/tls/common.js +145 -33
- package/node/prelude/internal/tls/wrap.js +182 -49
- package/node/prelude/internal/tls/x509.js +4 -1
- package/node/prelude/internal/udp.js +177 -0
- package/node/prelude/net.js +13 -1
- package/node/prelude/os.js +24 -6
- package/node/prelude/perf_hooks.js +37 -2
- package/node/prelude/punycode.js +2 -130
- package/node/prelude/readline.js +113 -4
- package/node/prelude/readline_promises.js +56 -32
- package/node/prelude/tls.js +21 -4
- package/node/prelude/util.js +3 -16
- package/node/src/host_dns.c +623 -0
- package/node/src/host_http.c +12 -0
- package/node/src/host_net.c +46 -0
- package/node/src/host_os.c +1 -6
- package/node/src/host_sys.c +70 -0
- package/node/src/host_udp.c +418 -0
- package/node/third_party/c-ares/LICENSE.md +24 -0
- package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
- package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
- package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
- package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
- package/node/third_party/c-ares/include/ares.h +1237 -0
- package/node/third_party/c-ares/include/ares_build.h +202 -0
- package/node/third_party/c-ares/include/ares_dns.h +127 -0
- package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
- package/node/third_party/c-ares/include/ares_nameser.h +510 -0
- package/node/third_party/c-ares/include/ares_version.h +47 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
- package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
- package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
- package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
- package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
- package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
- package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
- package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
- package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
- package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
- package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
- package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
- package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
- package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
- package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
- package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
- package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
- package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
- package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
- package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
- package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
- package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
- package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
- package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
- package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
- package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
- package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
- package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
- package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
- package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
- package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
- package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
- package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
- package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
- package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
- package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
- package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
- package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
- package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
- package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
- package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
- package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
- package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
- package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
- package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
- package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
- package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
- package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
- package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
- package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
- package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
- package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
- package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
- package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
- package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_builtins.h +5 -0
- package/runtime/include/js_crypto.h +11 -0
- package/runtime/include/js_gc.h +13 -10
- package/runtime/include/js_jobs.h +2 -0
- package/runtime/include/js_object.h +58 -0
- package/runtime/include/jscontext.h +1 -0
- package/runtime/src/crypto_internal.h +1 -0
- package/runtime/src/crypto_subtle.c +66 -7
- package/runtime/src/crypto_tls.c +265 -19
- package/runtime/src/gc.c +73 -92
- package/runtime/src/inspect.c +18 -1
- package/runtime/src/jobs.c +37 -22
- package/runtime/src/object.c +49 -2
- package/runtime/src/os.c +16 -6
- package/runtime/src/os.h +2 -0
- package/runtime/src/process.c +97 -10
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/* MIT License
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) John Schember
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
* Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: MIT
|
|
25
|
+
*/
|
|
26
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
|
27
|
+
# include "ares_private.h"
|
|
28
|
+
# include <jni.h>
|
|
29
|
+
# include <sys/prctl.h>
|
|
30
|
+
# include "ares_android.h"
|
|
31
|
+
|
|
32
|
+
static JavaVM *android_jvm = NULL;
|
|
33
|
+
static jobject android_connectivity_manager = NULL;
|
|
34
|
+
|
|
35
|
+
/* ConnectivityManager.getActiveNetwork */
|
|
36
|
+
static jmethodID android_cm_active_net_mid = NULL;
|
|
37
|
+
/* ConnectivityManager.getLinkProperties */
|
|
38
|
+
static jmethodID android_cm_link_props_mid = NULL;
|
|
39
|
+
/* LinkProperties.getDnsServers */
|
|
40
|
+
static jmethodID android_lp_dns_servers_mid = NULL;
|
|
41
|
+
/* LinkProperties.getDomains */
|
|
42
|
+
static jmethodID android_lp_domains_mid = NULL;
|
|
43
|
+
/* List.size */
|
|
44
|
+
static jmethodID android_list_size_mid = NULL;
|
|
45
|
+
/* List.get */
|
|
46
|
+
static jmethodID android_list_get_mid = NULL;
|
|
47
|
+
/* InetAddress.getHostAddress */
|
|
48
|
+
static jmethodID android_ia_host_addr_mid = NULL;
|
|
49
|
+
|
|
50
|
+
static jclass jni_get_class(JNIEnv *env, const char *path)
|
|
51
|
+
{
|
|
52
|
+
jclass cls = NULL;
|
|
53
|
+
|
|
54
|
+
if (env == NULL || path == NULL || *path == '\0') {
|
|
55
|
+
return NULL;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
cls = (*env)->FindClass(env, path);
|
|
59
|
+
if ((*env)->ExceptionOccurred(env)) {
|
|
60
|
+
(*env)->ExceptionClear(env);
|
|
61
|
+
return NULL;
|
|
62
|
+
}
|
|
63
|
+
return cls;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static jmethodID jni_get_method_id(JNIEnv *env, jclass cls,
|
|
67
|
+
const char *func_name, const char *signature)
|
|
68
|
+
{
|
|
69
|
+
jmethodID mid = NULL;
|
|
70
|
+
|
|
71
|
+
if (env == NULL || cls == NULL || func_name == NULL || *func_name == '\0' ||
|
|
72
|
+
signature == NULL || *signature == '\0') {
|
|
73
|
+
return NULL;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
mid = (*env)->GetMethodID(env, cls, func_name, signature);
|
|
77
|
+
if ((*env)->ExceptionOccurred(env)) {
|
|
78
|
+
(*env)->ExceptionClear(env);
|
|
79
|
+
return NULL;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return mid;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static int jvm_attach(JNIEnv **env)
|
|
86
|
+
{
|
|
87
|
+
char name[17] = { 0 };
|
|
88
|
+
|
|
89
|
+
JavaVMAttachArgs args;
|
|
90
|
+
|
|
91
|
+
args.version = JNI_VERSION_1_6;
|
|
92
|
+
if (prctl(PR_GET_NAME, name) == 0) {
|
|
93
|
+
args.name = name;
|
|
94
|
+
} else {
|
|
95
|
+
args.name = NULL;
|
|
96
|
+
}
|
|
97
|
+
args.group = NULL;
|
|
98
|
+
|
|
99
|
+
return (*android_jvm)->AttachCurrentThread(android_jvm, env, &args);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void ares_library_init_jvm(JavaVM *jvm)
|
|
103
|
+
{
|
|
104
|
+
android_jvm = jvm;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
int ares_library_init_android(jobject connectivity_manager)
|
|
108
|
+
{
|
|
109
|
+
JNIEnv *env = NULL;
|
|
110
|
+
int need_detatch = 0;
|
|
111
|
+
int res;
|
|
112
|
+
ares_status_t ret = ARES_ENOTINITIALIZED;
|
|
113
|
+
jclass obj_cls = NULL;
|
|
114
|
+
|
|
115
|
+
if (android_jvm == NULL) {
|
|
116
|
+
goto cleanup;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
|
|
120
|
+
if (res == JNI_EDETACHED) {
|
|
121
|
+
env = NULL;
|
|
122
|
+
res = jvm_attach(&env);
|
|
123
|
+
need_detatch = 1;
|
|
124
|
+
}
|
|
125
|
+
if (res != JNI_OK || env == NULL) {
|
|
126
|
+
goto cleanup;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
android_connectivity_manager =
|
|
130
|
+
(*env)->NewGlobalRef(env, connectivity_manager);
|
|
131
|
+
if (android_connectivity_manager == NULL) {
|
|
132
|
+
goto cleanup;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Initialization has succeeded. Now attempt to cache the methods that will be
|
|
136
|
+
* called by ares_get_android_server_list. */
|
|
137
|
+
ret = ARES_SUCCESS;
|
|
138
|
+
|
|
139
|
+
/* ConnectivityManager in API 1. */
|
|
140
|
+
obj_cls = jni_get_class(env, "android/net/ConnectivityManager");
|
|
141
|
+
if (obj_cls == NULL) {
|
|
142
|
+
goto cleanup;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* ConnectivityManager.getActiveNetwork in API 23. */
|
|
146
|
+
android_cm_active_net_mid = jni_get_method_id(
|
|
147
|
+
env, obj_cls, "getActiveNetwork", "()Landroid/net/Network;");
|
|
148
|
+
if (android_cm_active_net_mid == NULL) {
|
|
149
|
+
goto cleanup;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* ConnectivityManager.getLinkProperties in API 21. */
|
|
153
|
+
android_cm_link_props_mid =
|
|
154
|
+
jni_get_method_id(env, obj_cls, "getLinkProperties",
|
|
155
|
+
"(Landroid/net/Network;)Landroid/net/LinkProperties;");
|
|
156
|
+
if (android_cm_link_props_mid == NULL) {
|
|
157
|
+
goto cleanup;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* LinkProperties in API 21. */
|
|
161
|
+
(*env)->DeleteLocalRef(env, obj_cls);
|
|
162
|
+
obj_cls = jni_get_class(env, "android/net/LinkProperties");
|
|
163
|
+
if (obj_cls == NULL) {
|
|
164
|
+
goto cleanup;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* getDnsServers in API 21. */
|
|
168
|
+
android_lp_dns_servers_mid =
|
|
169
|
+
jni_get_method_id(env, obj_cls, "getDnsServers", "()Ljava/util/List;");
|
|
170
|
+
if (android_lp_dns_servers_mid == NULL) {
|
|
171
|
+
goto cleanup;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* getDomains in API 21. */
|
|
175
|
+
android_lp_domains_mid =
|
|
176
|
+
jni_get_method_id(env, obj_cls, "getDomains", "()Ljava/lang/String;");
|
|
177
|
+
if (android_lp_domains_mid == NULL) {
|
|
178
|
+
goto cleanup;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
(*env)->DeleteLocalRef(env, obj_cls);
|
|
182
|
+
obj_cls = jni_get_class(env, "java/util/List");
|
|
183
|
+
if (obj_cls == NULL) {
|
|
184
|
+
goto cleanup;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
android_list_size_mid = jni_get_method_id(env, obj_cls, "size", "()I");
|
|
188
|
+
if (android_list_size_mid == NULL) {
|
|
189
|
+
goto cleanup;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
android_list_get_mid =
|
|
193
|
+
jni_get_method_id(env, obj_cls, "get", "(I)Ljava/lang/Object;");
|
|
194
|
+
if (android_list_get_mid == NULL) {
|
|
195
|
+
goto cleanup;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
(*env)->DeleteLocalRef(env, obj_cls);
|
|
199
|
+
obj_cls = jni_get_class(env, "java/net/InetAddress");
|
|
200
|
+
if (obj_cls == NULL) {
|
|
201
|
+
goto cleanup;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
android_ia_host_addr_mid =
|
|
205
|
+
jni_get_method_id(env, obj_cls, "getHostAddress", "()Ljava/lang/String;");
|
|
206
|
+
if (android_ia_host_addr_mid == NULL) {
|
|
207
|
+
goto cleanup;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
(*env)->DeleteLocalRef(env, obj_cls);
|
|
211
|
+
goto done;
|
|
212
|
+
|
|
213
|
+
cleanup:
|
|
214
|
+
if (obj_cls != NULL) {
|
|
215
|
+
(*env)->DeleteLocalRef(env, obj_cls);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
android_cm_active_net_mid = NULL;
|
|
219
|
+
android_cm_link_props_mid = NULL;
|
|
220
|
+
android_lp_dns_servers_mid = NULL;
|
|
221
|
+
android_lp_domains_mid = NULL;
|
|
222
|
+
android_list_size_mid = NULL;
|
|
223
|
+
android_list_get_mid = NULL;
|
|
224
|
+
android_ia_host_addr_mid = NULL;
|
|
225
|
+
|
|
226
|
+
done:
|
|
227
|
+
if (need_detatch) {
|
|
228
|
+
(*android_jvm)->DetachCurrentThread(android_jvm);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return (int)ret;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
int ares_library_android_initialized(void)
|
|
235
|
+
{
|
|
236
|
+
if (android_jvm == NULL || android_connectivity_manager == NULL) {
|
|
237
|
+
return ARES_ENOTINITIALIZED;
|
|
238
|
+
}
|
|
239
|
+
return ARES_SUCCESS;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void ares_library_cleanup_android(void)
|
|
243
|
+
{
|
|
244
|
+
JNIEnv *env = NULL;
|
|
245
|
+
int need_detatch = 0;
|
|
246
|
+
int res;
|
|
247
|
+
|
|
248
|
+
if (android_jvm == NULL || android_connectivity_manager == NULL) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
|
|
253
|
+
if (res == JNI_EDETACHED) {
|
|
254
|
+
env = NULL;
|
|
255
|
+
res = jvm_attach(&env);
|
|
256
|
+
need_detatch = 1;
|
|
257
|
+
}
|
|
258
|
+
if (res != JNI_OK || env == NULL) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
android_cm_active_net_mid = NULL;
|
|
263
|
+
android_cm_link_props_mid = NULL;
|
|
264
|
+
android_lp_dns_servers_mid = NULL;
|
|
265
|
+
android_lp_domains_mid = NULL;
|
|
266
|
+
android_list_size_mid = NULL;
|
|
267
|
+
android_list_get_mid = NULL;
|
|
268
|
+
android_ia_host_addr_mid = NULL;
|
|
269
|
+
|
|
270
|
+
(*env)->DeleteGlobalRef(env, android_connectivity_manager);
|
|
271
|
+
android_connectivity_manager = NULL;
|
|
272
|
+
|
|
273
|
+
if (need_detatch) {
|
|
274
|
+
(*android_jvm)->DetachCurrentThread(android_jvm);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
char **ares_get_android_server_list(size_t max_servers, size_t *num_servers)
|
|
279
|
+
{
|
|
280
|
+
JNIEnv *env = NULL;
|
|
281
|
+
jobject active_network = NULL;
|
|
282
|
+
jobject link_properties = NULL;
|
|
283
|
+
jobject server_list = NULL;
|
|
284
|
+
jobject server = NULL;
|
|
285
|
+
jstring str = NULL;
|
|
286
|
+
jint nserv;
|
|
287
|
+
const char *ch_server_address;
|
|
288
|
+
int res;
|
|
289
|
+
size_t i;
|
|
290
|
+
char **dns_list = NULL;
|
|
291
|
+
int need_detatch = 0;
|
|
292
|
+
|
|
293
|
+
if (android_jvm == NULL || android_connectivity_manager == NULL ||
|
|
294
|
+
max_servers == 0 || num_servers == NULL) {
|
|
295
|
+
return NULL;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL ||
|
|
299
|
+
android_lp_dns_servers_mid == NULL || android_list_size_mid == NULL ||
|
|
300
|
+
android_list_get_mid == NULL || android_ia_host_addr_mid == NULL) {
|
|
301
|
+
return NULL;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
|
|
305
|
+
if (res == JNI_EDETACHED) {
|
|
306
|
+
env = NULL;
|
|
307
|
+
res = jvm_attach(&env);
|
|
308
|
+
need_detatch = 1;
|
|
309
|
+
}
|
|
310
|
+
if (res != JNI_OK || env == NULL) {
|
|
311
|
+
goto done;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* JNI below is equivalent to this Java code.
|
|
315
|
+
import android.content.Context;
|
|
316
|
+
import android.net.ConnectivityManager;
|
|
317
|
+
import android.net.LinkProperties;
|
|
318
|
+
import android.net.Network;
|
|
319
|
+
import java.net.InetAddress;
|
|
320
|
+
import java.util.List;
|
|
321
|
+
|
|
322
|
+
ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext()
|
|
323
|
+
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
324
|
+
Network an = cm.getActiveNetwork();
|
|
325
|
+
LinkProperties lp = cm.getLinkProperties(an);
|
|
326
|
+
List<InetAddress> dns = lp.getDnsServers();
|
|
327
|
+
for (InetAddress ia: dns) {
|
|
328
|
+
String ha = ia.getHostAddress();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
Note: The JNI ConnectivityManager object and all method IDs were previously
|
|
332
|
+
initialized in ares_library_init_android.
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
active_network = (*env)->CallObjectMethod(env, android_connectivity_manager,
|
|
336
|
+
android_cm_active_net_mid);
|
|
337
|
+
if (active_network == NULL) {
|
|
338
|
+
goto done;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
link_properties =
|
|
342
|
+
(*env)->CallObjectMethod(env, android_connectivity_manager,
|
|
343
|
+
android_cm_link_props_mid, active_network);
|
|
344
|
+
if (link_properties == NULL) {
|
|
345
|
+
goto done;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
server_list =
|
|
349
|
+
(*env)->CallObjectMethod(env, link_properties, android_lp_dns_servers_mid);
|
|
350
|
+
if (server_list == NULL) {
|
|
351
|
+
goto done;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
nserv = (*env)->CallIntMethod(env, server_list, android_list_size_mid);
|
|
355
|
+
if (nserv > (jint)max_servers) {
|
|
356
|
+
nserv = (jint)max_servers;
|
|
357
|
+
}
|
|
358
|
+
if (nserv <= 0) {
|
|
359
|
+
goto done;
|
|
360
|
+
}
|
|
361
|
+
*num_servers = (size_t)nserv;
|
|
362
|
+
|
|
363
|
+
dns_list = ares_malloc(sizeof(*dns_list) * (*num_servers));
|
|
364
|
+
for (i = 0; i < *num_servers; i++) {
|
|
365
|
+
size_t len = 64;
|
|
366
|
+
server =
|
|
367
|
+
(*env)->CallObjectMethod(env, server_list, android_list_get_mid, (jint)i);
|
|
368
|
+
dns_list[i] = ares_malloc(len);
|
|
369
|
+
dns_list[i][0] = 0;
|
|
370
|
+
if (server == NULL) {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
str = (*env)->CallObjectMethod(env, server, android_ia_host_addr_mid);
|
|
374
|
+
ch_server_address = (*env)->GetStringUTFChars(env, str, 0);
|
|
375
|
+
ares_strcpy(dns_list[i], ch_server_address, len);
|
|
376
|
+
(*env)->ReleaseStringUTFChars(env, str, ch_server_address);
|
|
377
|
+
(*env)->DeleteLocalRef(env, str);
|
|
378
|
+
(*env)->DeleteLocalRef(env, server);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
done:
|
|
382
|
+
if ((*env)->ExceptionOccurred(env)) {
|
|
383
|
+
(*env)->ExceptionClear(env);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (server_list != NULL) {
|
|
387
|
+
(*env)->DeleteLocalRef(env, server_list);
|
|
388
|
+
}
|
|
389
|
+
if (link_properties != NULL) {
|
|
390
|
+
(*env)->DeleteLocalRef(env, link_properties);
|
|
391
|
+
}
|
|
392
|
+
if (active_network != NULL) {
|
|
393
|
+
(*env)->DeleteLocalRef(env, active_network);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (need_detatch) {
|
|
397
|
+
(*android_jvm)->DetachCurrentThread(android_jvm);
|
|
398
|
+
}
|
|
399
|
+
return dns_list;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
char *ares_get_android_search_domains_list(void)
|
|
403
|
+
{
|
|
404
|
+
JNIEnv *env = NULL;
|
|
405
|
+
jobject active_network = NULL;
|
|
406
|
+
jobject link_properties = NULL;
|
|
407
|
+
jstring domains = NULL;
|
|
408
|
+
const char *domain;
|
|
409
|
+
int res;
|
|
410
|
+
char *domain_list = NULL;
|
|
411
|
+
int need_detatch = 0;
|
|
412
|
+
|
|
413
|
+
if (android_jvm == NULL || android_connectivity_manager == NULL) {
|
|
414
|
+
return NULL;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL ||
|
|
418
|
+
android_lp_domains_mid == NULL) {
|
|
419
|
+
return NULL;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
|
|
423
|
+
if (res == JNI_EDETACHED) {
|
|
424
|
+
env = NULL;
|
|
425
|
+
res = jvm_attach(&env);
|
|
426
|
+
need_detatch = 1;
|
|
427
|
+
}
|
|
428
|
+
if (res != JNI_OK || env == NULL) {
|
|
429
|
+
goto done;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* JNI below is equivalent to this Java code.
|
|
433
|
+
import android.content.Context;
|
|
434
|
+
import android.net.ConnectivityManager;
|
|
435
|
+
import android.net.LinkProperties;
|
|
436
|
+
|
|
437
|
+
ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext()
|
|
438
|
+
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
439
|
+
Network an = cm.getActiveNetwork();
|
|
440
|
+
LinkProperties lp = cm.getLinkProperties(an);
|
|
441
|
+
String domains = lp.getDomains();
|
|
442
|
+
for (String domain: domains.split(",")) {
|
|
443
|
+
String d = domain;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
Note: The JNI ConnectivityManager object and all method IDs were previously
|
|
447
|
+
initialized in ares_library_init_android.
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
active_network = (*env)->CallObjectMethod(env, android_connectivity_manager,
|
|
451
|
+
android_cm_active_net_mid);
|
|
452
|
+
if (active_network == NULL) {
|
|
453
|
+
goto done;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
link_properties =
|
|
457
|
+
(*env)->CallObjectMethod(env, android_connectivity_manager,
|
|
458
|
+
android_cm_link_props_mid, active_network);
|
|
459
|
+
if (link_properties == NULL) {
|
|
460
|
+
goto done;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/* Get the domains. It is a common separated list of domains to search. */
|
|
464
|
+
domains =
|
|
465
|
+
(*env)->CallObjectMethod(env, link_properties, android_lp_domains_mid);
|
|
466
|
+
if (domains == NULL) {
|
|
467
|
+
goto done;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* Split on , */
|
|
471
|
+
domain = (*env)->GetStringUTFChars(env, domains, 0);
|
|
472
|
+
domain_list = ares_strdup(domain);
|
|
473
|
+
(*env)->ReleaseStringUTFChars(env, domains, domain);
|
|
474
|
+
(*env)->DeleteLocalRef(env, domains);
|
|
475
|
+
|
|
476
|
+
done:
|
|
477
|
+
if ((*env)->ExceptionOccurred(env)) {
|
|
478
|
+
(*env)->ExceptionClear(env);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (link_properties != NULL) {
|
|
482
|
+
(*env)->DeleteLocalRef(env, link_properties);
|
|
483
|
+
}
|
|
484
|
+
if (active_network != NULL) {
|
|
485
|
+
(*env)->DeleteLocalRef(env, active_network);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (need_detatch) {
|
|
489
|
+
(*android_jvm)->DetachCurrentThread(android_jvm);
|
|
490
|
+
}
|
|
491
|
+
return domain_list;
|
|
492
|
+
}
|
|
493
|
+
#else
|
|
494
|
+
/* warning: ISO C forbids an empty translation unit */
|
|
495
|
+
typedef int dummy_make_iso_compilers_happy;
|
|
496
|
+
#endif
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* MIT License
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) John Schember
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
* Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: MIT
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
#ifndef __ARES_ANDROID_H__
|
|
28
|
+
#define __ARES_ANDROID_H__
|
|
29
|
+
|
|
30
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
|
31
|
+
|
|
32
|
+
char **ares_get_android_server_list(size_t max_servers, size_t *num_servers);
|
|
33
|
+
char *ares_get_android_search_domains_list(void);
|
|
34
|
+
void ares_library_cleanup_android(void);
|
|
35
|
+
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif /* __ARES_ANDROID_H__ */
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* MIT License
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2004 Daniel Stenberg
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
* Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: MIT
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
#include "ares_private.h"
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* ares_cancel() cancels all ongoing requests/resolves that might be going on
|
|
31
|
+
* on the given channel. It does NOT kill the channel, use ares_destroy() for
|
|
32
|
+
* that.
|
|
33
|
+
*/
|
|
34
|
+
void ares_cancel(ares_channel_t *channel)
|
|
35
|
+
{
|
|
36
|
+
if (channel == NULL) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ares_channel_lock(channel);
|
|
41
|
+
|
|
42
|
+
if (ares_llist_len(channel->all_queries) > 0) {
|
|
43
|
+
ares_llist_node_t *node = NULL;
|
|
44
|
+
ares_llist_node_t *next = NULL;
|
|
45
|
+
|
|
46
|
+
/* Swap list heads, so that only those queries which were present on entry
|
|
47
|
+
* into this function are cancelled. New queries added by callbacks of
|
|
48
|
+
* queries being cancelled will not be cancelled themselves.
|
|
49
|
+
*/
|
|
50
|
+
ares_llist_t *list_copy = channel->all_queries;
|
|
51
|
+
channel->all_queries = ares_llist_create(NULL);
|
|
52
|
+
|
|
53
|
+
/* Out of memory, this function doesn't return a result code though so we
|
|
54
|
+
* can't report to caller */
|
|
55
|
+
if (channel->all_queries == NULL) {
|
|
56
|
+
channel->all_queries = list_copy; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
57
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
node = ares_llist_node_first(list_copy);
|
|
61
|
+
while (node != NULL) {
|
|
62
|
+
ares_query_t *query;
|
|
63
|
+
|
|
64
|
+
/* Cache next since this node is being deleted */
|
|
65
|
+
next = ares_llist_node_next(node);
|
|
66
|
+
|
|
67
|
+
query = ares_llist_node_claim(node);
|
|
68
|
+
query->node_all_queries = NULL;
|
|
69
|
+
|
|
70
|
+
/* NOTE: its possible this may enqueue new queries */
|
|
71
|
+
query->callback(query->arg, ARES_ECANCELLED, 0, NULL);
|
|
72
|
+
ares_free_query(query);
|
|
73
|
+
|
|
74
|
+
node = next;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ares_llist_destroy(list_copy);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* See if the connections should be cleaned up */
|
|
81
|
+
ares_check_cleanup_conns(channel);
|
|
82
|
+
|
|
83
|
+
ares_queue_notify_empty(channel);
|
|
84
|
+
|
|
85
|
+
done:
|
|
86
|
+
ares_channel_unlock(channel);
|
|
87
|
+
}
|