summaryrefslogtreecommitdiff
path: root/Utilities/cmlibuv/src/unix/linux-core.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-15 10:43:50 -0400
committerBrad King <brad.king@kitware.com>2017-05-15 10:43:50 -0400
commited17516b31404dd42eab61c599c84933af485b34 (patch)
tree52538b48c172c7258117b1edcee4359dcf6c45e5 /Utilities/cmlibuv/src/unix/linux-core.c
parent52fbae0a59d05f2724e77aff75c7761b685bae03 (diff)
parent12a78bc824655524d817508d6107ef4dcf8e3626 (diff)
downloadcmake-ed17516b31404dd42eab61c599c84933af485b34.tar.gz
Merge branch 'upstream-libuv' into update-libuv
* upstream-libuv: libuv 2017-05-09 (e11dcd43) Fixes: #16878
Diffstat (limited to 'Utilities/cmlibuv/src/unix/linux-core.c')
-rw-r--r--Utilities/cmlibuv/src/unix/linux-core.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/Utilities/cmlibuv/src/unix/linux-core.c b/Utilities/cmlibuv/src/unix/linux-core.c
index 58dd813ddf..646be4fb1e 100644
--- a/Utilities/cmlibuv/src/unix/linux-core.c
+++ b/Utilities/cmlibuv/src/unix/linux-core.c
@@ -107,6 +107,24 @@ int uv__platform_loop_init(uv_loop_t* loop) {
}
+int uv__io_fork(uv_loop_t* loop) {
+ int err;
+ void* old_watchers;
+
+ old_watchers = loop->inotify_watchers;
+
+ uv__close(loop->backend_fd);
+ loop->backend_fd = -1;
+ uv__platform_loop_delete(loop);
+
+ err = uv__platform_loop_init(loop);
+ if (err)
+ return err;
+
+ return uv__inotify_fork(loop, old_watchers);
+}
+
+
void uv__platform_loop_delete(uv_loop_t* loop) {
if (loop->inotify_fd == -1) return;
uv__io_stop(loop, &loop->inotify_read_watcher, POLLIN);
@@ -868,6 +886,19 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
uv__free(cpu_infos);
}
+static int uv__ifaddr_exclude(struct ifaddrs *ent) {
+ if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
+ return 1;
+ if (ent->ifa_addr == NULL)
+ return 1;
+ /*
+ * On Linux getifaddrs returns information related to the raw underlying
+ * devices. We're not interested in this information yet.
+ */
+ if (ent->ifa_addr->sa_family == PF_PACKET)
+ return 1;
+ return 0;
+}
int uv_interface_addresses(uv_interface_address_t** addresses,
int* count) {
@@ -887,11 +918,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
- (ent->ifa_addr == NULL) ||
- (ent->ifa_addr->sa_family == PF_PACKET)) {
+ if (uv__ifaddr_exclude(ent))
continue;
- }
(*count)++;
}
@@ -908,17 +936,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
- continue;
-
- if (ent->ifa_addr == NULL)
- continue;
-
- /*
- * On Linux getifaddrs returns information related to the raw underlying
- * devices. We're not interested in this information yet.
- */
- if (ent->ifa_addr->sa_family == PF_PACKET)
+ if (uv__ifaddr_exclude(ent))
continue;
address->name = uv__strdup(ent->ifa_name);
@@ -942,11 +960,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
/* Fill in physical addresses for each interface */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)) ||
- (ent->ifa_addr == NULL) ||
- (ent->ifa_addr->sa_family != PF_PACKET)) {
+ if (uv__ifaddr_exclude(ent))
continue;
- }
address = *addresses;