summaryrefslogtreecommitdiffstats
path: root/src/unix/linux-core.c
diff options
context:
space:
mode:
authorlibuv upstream <libuv@googlegroups.com>2017-05-09 19:51:26 (GMT)
committerBrad King <brad.king@kitware.com>2017-05-15 14:43:03 (GMT)
commit12a78bc824655524d817508d6107ef4dcf8e3626 (patch)
tree39bcf5989f7696efbb2cb777b1ce5b0062df7939 /src/unix/linux-core.c
parent1f661e87a6a8304edb77bd30b546e5d113477c59 (diff)
downloadCMake-12a78bc824655524d817508d6107ef4dcf8e3626.zip
CMake-12a78bc824655524d817508d6107ef4dcf8e3626.tar.gz
CMake-12a78bc824655524d817508d6107ef4dcf8e3626.tar.bz2
libuv 2017-05-09 (e11dcd43)
Code extracted from: https://github.com/libuv/libuv.git at commit e11dcd4377185359874e67f4962995fdb7e83d19 (v1.x).
Diffstat (limited to 'src/unix/linux-core.c')
-rw-r--r--src/unix/linux-core.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index 58dd813..646be4f 100644
--- a/src/unix/linux-core.c
+++ b/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;