]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Avoid caching HDHomeRun's IP address
authorKin-Wai Koo <glug71@gmail.com>
Tue, 22 Jan 2019 00:52:39 +0000 (08:52 +0800)
committerJaroslav Kysela <perex@perex.cz>
Mon, 4 Feb 2019 10:07:17 +0000 (11:07 +0100)
src/input/mpegts/tvhdhomerun/tvhdhomerun.c

index cf1184214f523bc795e75b8f674110aad4443a22..4f17d0ef851bb81c5daf3b3c97f336f03ab8ef8a 100644 (file)
@@ -387,18 +387,14 @@ static void tvhdhomerun_device_create(struct hdhomerun_discover_device_t *dInfo)
 static uint32_t
 tvhdhomerun_ip( void )
 {
-  static int homerun_ip_initialized = 0;
-  static uint32_t ip = 0;
+  if (*config.hdhomerun_ip == 0) return 0;
+
+  uint32_t ip = 0;
+  if (inet_pton(AF_INET, config.hdhomerun_ip, &ip))
+    ip = ntohl(ip);
+  else
+    tvhwarn(LS_TVHDHOMERUN, "Could not parse IP address %s", config.hdhomerun_ip);
 
-  if (!homerun_ip_initialized)
-  {
-    if ((*config.hdhomerun_ip != 0) && inet_pton(AF_INET, config.hdhomerun_ip, &ip))
-    {
-      tvhinfo(LS_TVHDHOMERUN, "HDHomerun IP set to %s", config.hdhomerun_ip);
-      ip = ntohl(ip);
-    }
-    homerun_ip_initialized = 1;
-  }
   return ip;
 }