You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 08:42:36 UTC

svn commit: r1131965 - /incubator/mesos/trunk/src/slave.cpp

Author: benh
Date: Sun Jun  5 06:42:35 2011
New Revision: 1131965

URL: http://svn.apache.org/viewvc?rev=1131965&view=rev
Log:
Fixed a rather nasty bug that Andy and Petri found on the Helsinki
cluster: gethostbyname2 returns a pointer to data that might later be
modified by another call to gethostname or similar functions. This was
causing the slave to report a different hostname to the master than it
reports to the executors, which was causing Hadoop to fail to identify
its slaves properly. The fix was to copy the hostname returned by
gethostbyname2.

Modified:
    incubator/mesos/trunk/src/slave.cpp

Modified: incubator/mesos/trunk/src/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave.cpp?rev=1131965&r1=1131964&r2=1131965&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave.cpp Sun Jun  5 06:42:35 2011
@@ -133,14 +133,14 @@ void Slave::operator () ()
   char buf[256];
   gethostname(buf, sizeof(buf));
   hostent *he = gethostbyname2(buf, AF_INET);
-  const char *hostname = he->h_name;
+  string hostname = he->h_name;
 
   // Get our public DNS name. Normally this is our hostname, but on EC2
   // we look for the MESOS_PUBLIC_DNS environment variable. This allows
   // the master to display our public name in its web UI.
-  const char *publicDns = getenv("MESOS_PUBLIC_DNS");
-  if (!publicDns) {
-    publicDns = hostname;
+  string publicDns = hostname;
+  if (getenv("MESOS_PUBLIC_DNS") != NULL) {
+    publicDns = getenv("MESOS_PUBLIC_DNS");
   }
 
   // Initialize isolation module.