You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/01/21 02:09:26 UTC
[3/4] mesos git commit: Windows: Set `MAXHOSTNAMELEN` to an
appropriate value.
Windows: Set `MAXHOSTNAMELEN` to an appropriate value.
The POSIX standard defines a function `getnameinfo`, but does not
specify a maximum length that a hostname can have. To simplify the logic
of choosing a reasonable buffer size to hold the hostname, most
implementations of this specification expose an additional symbol (e.g.,
NI_MAXHOST) that represents the maximum length a hostname can have.
Our code uses `MAXHOSTNAMELEN`, and so on platforms where this symbol is
not implemented (such as Windows), it is necessary to define it.
Currently, `stout/windows.hpp` defines this to be `64`. This value was
chosen because other popular codebases seemed to use this value. But, as
MESOS-3398 explains, we were never sure that this was correct.
Now we have compelling evidence that it isn't: the Windows documentation
for `getnameinfo` clearly states that the maximum length of a hostname
must is captured as `NI_MAXHOST`, and in all recent versions of the
standard libraries, the value of this symbol is 1025.
Hence, for machines with a hostname longer than 64 bytes, almost all the
tests will abort mysteriously, with a cryptic error that claims that the
"data area passed to a system call is too small", which essentially
means that this particular buffer is too small to hold the hostname.
This commit will cause this value to be correctly set on Windows.
Review: https://reviews.apache.org/r/55544/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f2b4d90f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f2b4d90f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f2b4d90f
Branch: refs/heads/master
Commit: f2b4d90f9ad70021d8310deaac501a42da1fb45a
Parents: efc49d8
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Jan 20 16:32:28 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Jan 20 16:57:54 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/windows.hpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f2b4d90f/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index d89c709..8238704 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -141,9 +141,7 @@ inline BOOL GetMessage(
#define O_APPEND _O_APPEND
#define O_CLOEXEC _O_NOINHERIT
-// TODO(hausdorff): (MESOS-3398) Not defined on Windows. This value is
-// temporary.
-#define MAXHOSTNAMELEN 64
+#define MAXHOSTNAMELEN NI_MAXHOST
#define PATH_MAX _MAX_PATH