[vlc-commits] [Git][videolan/vlc][master] contrib/upnp: disable usage of reuseaddr on iOS/tvOS and fix option

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat May 13 11:57:43 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
74b765d8 by Felix Paul Kühne at 2023-05-13T11:12:30+00:00
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

- - - - -


2 changed files:

- + contrib/src/upnp/fix-reuseaddr-option.patch
- contrib/src/upnp/rules.mak


Changes:

=====================================
contrib/src/upnp/fix-reuseaddr-option.patch
=====================================
@@ -0,0 +1,51 @@
+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,


=====================================
contrib/src/upnp/rules.mak
=====================================
@@ -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



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/74b765d81cb5081eeb012887a4016dc9decd4675

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/74b765d81cb5081eeb012887a4016dc9decd4675
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list