Skip to content
Snippets Groups Projects
Commit 74b765d8 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

contrib/upnp: disable usage of reuseaddr on iOS/tvOS and fix option

Use of SO_REUSEADDR leads to a busy loop within libupnp and very high
battery usage. This disables the option and actually fixes its
functionality by patching the library. Patch to be upstreamed.

According to App Store analytics, this is the most prominent source of
high CPU load and battery use, so it could explain #27036
parent 4c625465
No related branches found
No related tags found
1 merge request!3659contrib/upnp: disable usage of reuseaddr on iOS/tvOS and fix option
Pipeline #342387 passed with stage
in 51 minutes and 37 seconds
diff -ru upnp/upnp/src/ssdp/ssdp_server.c upnp/upnp/src/ssdp/ssdp_server.c
--- upnp/upnp/src/ssdp/ssdp_server.c 2022-08-03 16:05:12
+++ upnp/upnp/src/ssdp/ssdp_server.c 2023-05-11 12:13:42
@@ -928,6 +928,7 @@
return UPNP_E_OUTOF_SOCKET;
}
+#ifdef UPNP_MINISERVER_REUSEADDR
onOff = 1;
ret = setsockopt(*ssdpSock,
SOL_SOCKET,
@@ -945,6 +946,7 @@
ret = UPNP_E_SOCKET_ERROR;
goto error_handler;
}
+#endif
#if (defined(BSD) && !defined(__GNU__)) || defined(__APPLE__)
onOff = 1;
ret = setsockopt(*ssdpSock,
@@ -1133,6 +1135,7 @@
return UPNP_E_OUTOF_SOCKET;
}
onOff = 1;
+#ifdef UPNP_MINISERVER_REUSEADDR
ret = setsockopt(*ssdpSock,
SOL_SOCKET,
SO_REUSEADDR,
@@ -1149,6 +1152,7 @@
ret = UPNP_E_SOCKET_ERROR;
goto error_handler;
}
+#endif
#if (defined(BSD) && !defined(__GNU__)) || defined(__APPLE__)
onOff = 1;
ret = setsockopt(*ssdpSock,
@@ -1313,6 +1317,7 @@
return UPNP_E_OUTOF_SOCKET;
}
onOff = 1;
+#ifdef UPNP_MINISERVER_REUSEADDR
ret = setsockopt(*ssdpSock,
SOL_SOCKET,
SO_REUSEADDR,
@@ -1329,6 +1334,7 @@
ret = UPNP_E_SOCKET_ERROR;
goto error_handler;
}
+#endif
#if (defined(BSD) && !defined(__GNU__)) || defined(__APPLE__)
onOff = 1;
ret = setsockopt(*ssdpSock,
......@@ -26,7 +26,8 @@ ifdef HAVE_WINSTORE
UPNP_CONF += -DUPNP_ENABLE_IPV6=OFF -DUPNP_ENABLE_UNSPECIFIED_SERVER=ON
else
ifdef HAVE_IOS
UPNP_CONF += -DUPNP_ENABLE_IPV6=OFF -DUPNP_ENABLE_UNSPECIFIED_SERVER=ON
UPNP_CONF += -DUPNP_ENABLE_IPV6=OFF -DUPNP_ENABLE_UNSPECIFIED_SERVER=ON \
-DUPNP_MINISERVER_REUSEADDR=OFF
else
UPNP_CONF += -DUPNP_ENABLE_IPV6=ON
endif
......@@ -46,6 +47,9 @@ else
$(APPLY) $(SRC)/upnp/libtool-nostdlib-workaround.patch
endif
$(APPLY) $(SRC)/upnp/miniserver.patch
ifdef HAVE_IOS
$(APPLY) $(SRC)/upnp/fix-reuseaddr-option.patch
endif
$(MOVE)
.upnp: upnp toolchain.cmake
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment