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 05:18:59 UTC

svn commit: r1131532 - /incubator/mesos/trunk/src/third_party/libprocess/process.cpp

Author: benh
Date: Sun Jun  5 03:18:59 2011
New Revision: 1131532

URL: http://svn.apache.org/viewvc?rev=1131532&view=rev
Log:
On Mac OS X the implementation of inet_ntoa is not thread-safe (POSIX doesn't require it to be thread safe) and this can cause a bug (you'll get a string representation of a PID with '[inet_ntoa error]').

Modified:
    incubator/mesos/trunk/src/third_party/libprocess/process.cpp

Modified: incubator/mesos/trunk/src/third_party/libprocess/process.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/third_party/libprocess/process.cpp?rev=1131532&r1=1131531&r2=1131532&view=diff
==============================================================================
--- incubator/mesos/trunk/src/third_party/libprocess/process.cpp (original)
+++ incubator/mesos/trunk/src/third_party/libprocess/process.cpp Sun Jun  5 03:18:59 2011
@@ -299,8 +299,12 @@ bool PID::operator ! () const
 
 std::ostream& operator << (std::ostream& stream, const PID& pid)
 {
-  stream << pid.pipe << "@" << inet_ntoa(*((in_addr *) &pid.ip))
-         << ":" << pid.port;
+  /* Call inet_ntop since inet_ntoa is not thread-safe! */
+  char ip[INET_ADDRSTRLEN];
+  if (inet_ntop(AF_INET, (in_addr *) &pid.ip, ip, INET_ADDRSTRLEN) == NULL)
+    memset(ip, 0, INET_ADDRSTRLEN);
+
+  stream << pid.pipe << "@" << ip << ":" << pid.port;
   return stream;
 }