瀏覽代碼

Merge pull request #873 from ghalliday/socket

Always call getInterfaceIp to find the host IP

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 年之前
父節點
當前提交
e8a8d0896d
共有 1 個文件被更改,包括 10 次插入11 次删除
  1. 10 11
      system/jlib/jsocket.cpp

+ 10 - 11
system/jlib/jsocket.cpp

@@ -2572,23 +2572,22 @@ const char * GetCachedHostName()
     if (!cachehostname.get())
     {
 #ifndef _WIN32
-        StringBuffer ifs;
         IpAddress ip;
         if (EnvConfPath.length() == 0)
             EnvConfPath.append(CONFIG_DIR).append(PATHSEPSTR).append("environment.conf");
         Owned<IProperties> conf = createProperties(EnvConfPath.str(), true);
-        if (conf->getProp("interface", ifs) && ifs.length())
+
+        StringBuffer ifs;
+        conf->getProp("interface", ifs);
+        if (getInterfaceIp(ip, ifs.str()))
         {
-            if (getInterfaceIp(ip, ifs.str()))
+            StringBuffer ips;
+            ip.getIpText(ips);
+            if (ips.length())
             {
-                StringBuffer ips;
-                ip.getIpText(ips);
-                if (ips.length())
-                {
-                    cachehostname.set(ips.str());
-                    cachehostip.ipset(ip);
-                    return cachehostname.get();
-                }
+                cachehostname.set(ips.str());
+                cachehostip.ipset(ip);
+                return cachehostname.get();
             }
         }
 #endif