From 3496e4747511a00e816a1134780fdad7f535fce6 Mon Sep 17 00:00:00 2001 From: zhuzeitou Date: Wed, 3 Apr 2024 01:03:41 +0800 Subject: [PATCH] Optimize Net module for Android (#4517) * epoll is available on Android * is introduced in android-24 --- Net/include/Poco/Net/Net.h | 2 +- Net/src/NetworkInterface.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Net/include/Poco/Net/Net.h b/Net/include/Poco/Net/Net.h index 98780164d..3934b972c 100644 --- a/Net/include/Poco/Net/Net.h +++ b/Net/include/Poco/Net/Net.h @@ -134,7 +134,7 @@ POCO_NET_FORCE_SYMBOL(pocoNetworkInitializer) #endif -#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_WINDOWS_NT) +#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_WINDOWS_NT) || (POCO_OS == POCO_OS_ANDROID) #define POCO_HAVE_FD_EPOLL 1 #endif diff --git a/Net/src/NetworkInterface.cpp b/Net/src/NetworkInterface.cpp index 0002c316d..bb8940b22 100644 --- a/Net/src/NetworkInterface.cpp +++ b/Net/src/NetworkInterface.cpp @@ -1486,7 +1486,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly) #include -#if POCO_OS != POCO_OS_ANDROID // Android doesn't have +#if POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24 // old Android doesn't have #include #endif #include @@ -1521,7 +1521,7 @@ static NetworkInterface::Type fromNative(unsigned arphrd) } } -#if (POCO_OS != POCO_OS_ANDROID) && !defined(POCO_EMSCRIPTEN) +#if (POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24) && !defined(POCO_EMSCRIPTEN) void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl) { @@ -1580,7 +1580,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl) NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly) { -#if (POCO_OS != POCO_OS_ANDROID) && !defined(POCO_EMSCRIPTEN) +#if (POCO_OS != POCO_OS_ANDROID || __ANDROID_API__ >= 24) && !defined(POCO_EMSCRIPTEN) FastMutex::ScopedLock lock(_mutex); Map result; unsigned ifIndex = 0;