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/10/11 22:37:03 UTC

[1/6] mesos git commit: Windows: Added `intptr_t` constructor for `WindowsFD`.

Repository: mesos
Updated Branches:
  refs/heads/master 8c0b3512e -> 1a5b99f79


Windows: Added `intptr_t` constructor for `WindowsFD`.

This is the inverse of the existing explicit cast required for the
socket type used by libevent on Windows.

Review: https://reviews.apache.org/r/62509/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1cf13ee9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1cf13ee9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1cf13ee9

Branch: refs/heads/master
Commit: 1cf13ee96d5411580b325020440624dff357a2ed
Parents: 8c0b351
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Oct 11 14:26:30 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 14:26:30 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/windows/fd.hpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1cf13ee9/3rdparty/stout/include/stout/os/windows/fd.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/fd.hpp b/3rdparty/stout/include/stout/os/windows/fd.hpp
index 8f31f46..d7f8cdf 100644
--- a/3rdparty/stout/include/stout/os/windows/fd.hpp
+++ b/3rdparty/stout/include/stout/os/windows/fd.hpp
@@ -81,6 +81,11 @@ public:
 
   WindowsFD(SOCKET socket) : type_(FD_SOCKET), socket_(socket) {}
 
+  // On Windows, libevent's `evutil_socket_t` is set to `intptr_t`.
+  WindowsFD(intptr_t socket)
+    : type_(FD_SOCKET),
+      socket_(static_cast<SOCKET>(socket)) {}
+
   WindowsFD(const WindowsFD&) = default;
   WindowsFD(WindowsFD&&) = default;
 
@@ -107,7 +112,6 @@ public:
     return socket_;
   }
 
-  // On Windows, libevent's `evutil_socket_t` is set to `intptr_t`.
   operator intptr_t() const
   {
     CHECK_EQ(FD_SOCKET, type());


[6/6] mesos git commit: Windows: Disabled RestartSlaveRequireExecutorAuthentication test.

Posted by jo...@apache.org.
Windows: Disabled RestartSlaveRequireExecutorAuthentication test.

This test became enabled when building with OpenSSL on Windows. The
first part of the test failed because of the use of the Linux command
`cat` to launch an indefinitely running task. This was fixed by using
`more` on Windows. However, the test subsequently fails when recoverying
to due "incompatible agent info", an existing bug: MESOS-7604.

Review: https://reviews.apache.org/r/62512/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1a5b99f7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1a5b99f7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1a5b99f7

Branch: refs/heads/master
Commit: 1a5b99f797854c1c107377d9fc40f99c0e864d94
Parents: 5212106
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Oct 11 15:14:29 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 15:14:29 2017 -0700

----------------------------------------------------------------------
 src/tests/slave_tests.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1a5b99f7/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 2ff6dab..6d1e98d 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -6766,7 +6766,11 @@ TEST_F(SlaveTest, RunTaskGroupGenerateSecretAfterShutdown)
 // generation is enabled and HTTP executor authentication is not required will
 // be able to re-subscribe successfully when the agent is restarted with
 // required HTTP executor authentication.
-TEST_F(SlaveTest, RestartSlaveRequireExecutorAuthentication)
+//
+// TODO(andschwa): Enable this test after fixing MESOS-7604.
+TEST_F_TEMP_DISABLED_ON_WINDOWS(
+    SlaveTest,
+    RestartSlaveRequireExecutorAuthentication)
 {
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
@@ -6839,7 +6843,13 @@ TEST_F(SlaveTest, RestartSlaveRequireExecutorAuthentication)
     v1::Resources::parse("cpus:0.1;mem:32;disk:32").get();
 
   // Create a task which should run indefinitely.
-  v1::TaskInfo taskInfo = v1::createTask(agentId, resources, "cat");
+  const string command =
+#ifdef __WINDOWS__
+    "more";
+#else
+    "cat";
+#endif // __WINDOWS__
+  v1::TaskInfo taskInfo = v1::createTask(agentId, resources, command);
 
   v1::TaskGroupInfo taskGroup;
   taskGroup.add_tasks()->CopyFrom(taskInfo);


[3/6] mesos git commit: CMake: Added documentation about `CMAKE_SSL_FORWARD_ARGS`.

Posted by jo...@apache.org.
CMake: Added documentation about `CMAKE_SSL_FORWARD_ARGS`.

This is a variable that is used by Libevent and cURL during
configuration time.  The variable is used to syncronize the
options used to build/link OpenSSL between 3rdparty dependencies.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e76759a3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e76759a3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e76759a3

Branch: refs/heads/master
Commit: e76759a366c60f4525f38bd10739066f7ce67fa0
Parents: d603101
Author: Joseph Wu <jo...@apache.org>
Authored: Wed Oct 11 14:48:02 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 14:48:02 2017 -0700

----------------------------------------------------------------------
 docs/cmake.md | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e76759a3/docs/cmake.md
----------------------------------------------------------------------
diff --git a/docs/cmake.md b/docs/cmake.md
index 74df542..1e1a27e 100644
--- a/docs/cmake.md
+++ b/docs/cmake.md
@@ -309,6 +309,12 @@ CMake project. If either the `CONFIGURE_COMMAND` or `BUILD_COMMAND` arguments of
 This variable ensures that compilation configurations are properly propagated to
 third-party dependencies, such as compiler flags.
 
+### `CMAKE_SSL_FORWARD_ARGS`
+
+The `CMAKE_SSL_FORWARD_ARGS` variable defined in `3rdparty/CMakeLists.txt`
+is like `CMAKE_FORWARD_ARGS`, but only used for specific external projects
+that find and link against OpenSSL.
+
 ## `LIBRARY_LINKAGE`
 
 This variable is a shortcut used in `3rdparty/CMakeLists.txt`. It is set to


[2/6] mesos git commit: CMake: Updated 3rdparty build rules regarding OpenSSL.

Posted by jo...@apache.org.
CMake: Updated 3rdparty build rules regarding OpenSSL.

Specifically we now forward all possible hints to `FindOpenSSL` to the
`libevent` and `curl` libraries, as they need to use SSL in the same
configured manner. Furthermore, we explicitly always set `curl` to
enable or disable its use of OpenSSL based on our use, as otherwise it
may detect an OpenSSL installation and cause conflicts (this is the same
as we already do for `libevent`.

We also prefer the multi-threaded version of OpenSSL on Windows.

Review: https://reviews.apache.org/r/62740/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d6031015
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d6031015
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d6031015

Branch: refs/heads/master
Commit: d6031015af7686ecc7d4d48068cbe77f8f002f08
Parents: 1cf13ee
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Oct 11 14:32:15 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 14:47:05 2017 -0700

----------------------------------------------------------------------
 3rdparty/CMakeLists.txt          | 37 +++++++++++++++++++++++++++--------
 cmake/CompilationConfigure.cmake |  6 ++++++
 2 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d6031015/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 4e10631..a37a8c6 100755
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -120,6 +120,25 @@ foreach (lang C CXX)
   endforeach ()
 endforeach ()
 
+# For 3rdparty dependencies that use CMake to find and build against
+# OpenSSL, we forward any user-supplied options for the `FindOpenSSL` module.
+if (ENABLE_SSL)
+  if (OPENSSL_ROOT_DIR)
+    list(APPEND CMAKE_SSL_FORWARD_ARGS
+      -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR})
+  endif ()
+
+  if (OPENSSL_USE_STATIC_LIBS)
+    list(APPEND CMAKE_SSL_FORWARD_ARGS
+      -DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS})
+  endif ()
+
+  if (OPENSSL_MSVC_STATIC_RT)
+    list(APPEND CMAKE_SSL_FORWARD_ARGS
+      -DOPENSSL_MSVC_STATIC_RT=${OPENSSL_MSVC_STATIC_RT})
+  endif ()
+endif ()
+
 # This function works around a CMake issue with setting include directories of
 # imported libraries built with `ExternalProject_Add`.
 # https://gitlab.kitware.com/cmake/cmake/issues/15052
@@ -426,8 +445,9 @@ if (ENABLE_LIBEVENT)
   endif ()
 
   set(LIBEVENT_CMAKE_ARGS
-    # NOTE: Libevent does not respect the BUILD_SHARED_LIBS global flag.
     ${CMAKE_FORWARD_ARGS}
+    ${CMAKE_SSL_FORWARD_ARGS}
+    # NOTE: Libevent does not respect the BUILD_SHARED_LIBS global flag.
     -DEVENT__BUILD_SHARED_LIBRARIES=${BUILD_SHARED_LIBS}
     -DEVENT__DISABLE_OPENSSL=$<NOT:$<BOOL:${ENABLE_SSL}>>
     -DCMAKE_C_FLAGS=$<IF:$<PLATFORM_ID:Windows>,"",-fPIC>
@@ -436,10 +456,6 @@ if (ENABLE_LIBEVENT)
     -DEVENT__DISABLE_SAMPLES=ON
     -DEVENT__DISABLE_TESTS=ON)
 
-  if (OPENSSL_ROOT_DIR)
-    list(APPEND LIBEVENT_CMAKE_ARGS -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR})
-  endif ()
-
   MAKE_INCLUDE_DIR(libevent)
   GET_BYPRODUCTS(libevent)
 
@@ -541,7 +557,7 @@ if (NOT WIN32)
 endif ()
 
 
-# curl: Command line tool and library for transferring data with URLs.
+# cURL: Command line tool and library for transferring data with URLs.
 # https://curl.haxx.se
 ######################################################################
 if (WIN32)
@@ -549,8 +565,13 @@ if (WIN32)
   add_library(curl ${LIBRARY_LINKAGE} IMPORTED GLOBAL)
   add_dependencies(curl ${CURL_TARGET})
 
-  # NOTE: curl does not respect BUILD_SHARED_LIBS.
-  set(CURL_CMAKE_ARGS ${CMAKE_FORWARD_ARGS} -DBUILD_CURL_TESTS=OFF)
+  set(CURL_CMAKE_ARGS
+    ${CMAKE_FORWARD_ARGS}
+    ${CMAKE_SSL_FORWARD_ARGS}
+    -DBUILD_CURL_TESTS=OFF
+    -DCMAKE_USE_OPENSSL=${ENABLE_SSL})
+
+  # NOTE: cURL does not respect BUILD_SHARED_LIBS.
   if (NOT BUILD_SHARED_LIBS)
     # This is both a CMake argument and a pre-processor definition.
     list(APPEND CURL_CMAKE_ARGS -DCURL_STATICLIB=ON)

http://git-wip-us.apache.org/repos/asf/mesos/blob/d6031015/cmake/CompilationConfigure.cmake
----------------------------------------------------------------------
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index a94cfa1..929e45b 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -277,6 +277,12 @@ if (WIN32)
     set(CRT " /MT")
   endif ()
 
+  if (ENABLE_SSL)
+    # NOTE: We don't care about using the debug version because OpenSSL includes
+    # an adapter. However, we prefer OpenSSL to use the multi-threaded CRT.
+    set(OPENSSL_MSVC_STATIC_RT TRUE)
+  endif ()
+
   # NOTE: We APPEND ${CRT} rather than REPLACE so it gets picked up by
   # dependencies.
   foreach (lang C CXX)


[4/6] mesos git commit: Updated `LibeventSSLSocketImpl` for Windows file descriptors.

Posted by jo...@apache.org.
Updated `LibeventSSLSocketImpl` for Windows file descriptors.

This patch introduces the `int_fd` abstraction we use elsewhere to the
`LibeventSSLSocketImpl` for dealing with Linux versus Windows file
descriptors. This is necessary because on Windows, the consumer of
`LibeventSSLSocketImpl::create()` etc. already use `int_fd`.

Note that this does not break Linux systems, as `int_fd` is defined as
`int` on all non-Windows systems.

On Windows, however, in `evbuffer_add_file` we must explicitly convert
from `int_fd` (holding a Windows file handle) to a CRT `int` file
descriptor (the platform-specific call to `crt()`).

We have to correct the type expected by `evconnlistener_new` from `int`
to `evutil_socket_t`. This previously worked as just an `int` because
that is the underlying type used for sockets by libevent on Linux, but
it instead uses `intptr_t` on Windows. The `int_fd` abstraction can be
casted to `intptr_t` (and thus `evutil_socket_t`) automatically, but not
`int`, and so correcting the type to `evutil_socket_t` allows us to use
this lambda for the listener.

Review: https://reviews.apache.org/r/62510/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f06e6184
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f06e6184
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f06e6184

Branch: refs/heads/master
Commit: f06e6184b0d6cc4a3245a714e5b56f26eb454233
Parents: e76759a
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Oct 11 14:54:58 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 14:54:58 2017 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/libevent_ssl_socket.cpp | 12 ++++++++----
 3rdparty/libprocess/src/libevent_ssl_socket.hpp | 10 +++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f06e6184/3rdparty/libprocess/src/libevent_ssl_socket.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent_ssl_socket.cpp b/3rdparty/libprocess/src/libevent_ssl_socket.cpp
index 5767ce0..1c95eba 100644
--- a/3rdparty/libprocess/src/libevent_ssl_socket.cpp
+++ b/3rdparty/libprocess/src/libevent_ssl_socket.cpp
@@ -84,7 +84,7 @@ namespace process {
 namespace network {
 namespace internal {
 
-Try<std::shared_ptr<SocketImpl>> LibeventSSLSocketImpl::create(int s)
+Try<std::shared_ptr<SocketImpl>> LibeventSSLSocketImpl::create(int_fd s)
 {
   openssl::initialize();
 
@@ -476,7 +476,7 @@ void LibeventSSLSocketImpl::event_callback(short events)
 }
 
 
-LibeventSSLSocketImpl::LibeventSSLSocketImpl(int _s)
+LibeventSSLSocketImpl::LibeventSSLSocketImpl(int_fd _s)
   : SocketImpl(_s),
     bev(nullptr),
     listener(nullptr),
@@ -487,7 +487,7 @@ LibeventSSLSocketImpl::LibeventSSLSocketImpl(int _s)
 
 
 LibeventSSLSocketImpl::LibeventSSLSocketImpl(
-    int _s,
+    int_fd _s,
     bufferevent* _bev,
     Option<string>&& _peer_hostname)
   : SocketImpl(_s),
@@ -855,7 +855,11 @@ Future<size_t> LibeventSSLSocketImpl::sendfile(
           // descriptor and close it after it has finished reading it.
           int result = evbuffer_add_file(
               bufferevent_get_output(self->bev),
+#ifdef __WINDOWS__
+              owned_fd.crt(),
+#else
               owned_fd,
+#endif // __WINDOWS__
               offset,
               size);
           CHECK_EQ(0, result);
@@ -883,7 +887,7 @@ Try<Nothing> LibeventSSLSocketImpl::listen(int backlog)
   listener = evconnlistener_new(
       base,
       [](evconnlistener* listener,
-         int socket,
+         evutil_socket_t socket,
          sockaddr* addr,
          int addr_length,
          void* arg) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/f06e6184/3rdparty/libprocess/src/libevent_ssl_socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent_ssl_socket.hpp b/3rdparty/libprocess/src/libevent_ssl_socket.hpp
index 9493a50..640fa67 100644
--- a/3rdparty/libprocess/src/libevent_ssl_socket.hpp
+++ b/3rdparty/libprocess/src/libevent_ssl_socket.hpp
@@ -33,9 +33,9 @@ class LibeventSSLSocketImpl : public SocketImpl
 {
 public:
   // See 'Socket::create()'.
-  static Try<std::shared_ptr<SocketImpl>> create(int s);
+  static Try<std::shared_ptr<SocketImpl>> create(int_fd s);
 
-  LibeventSSLSocketImpl(int _s);
+  LibeventSSLSocketImpl(int_fd _s);
 
   ~LibeventSSLSocketImpl() override;
 
@@ -71,7 +71,7 @@ private:
   struct AcceptRequest
   {
     AcceptRequest(
-        int _socket,
+        int_fd _socket,
         evconnlistener* _listener,
         const Option<net::IP>& _ip)
       : peek_event(nullptr),
@@ -81,7 +81,7 @@ private:
     event* peek_event;
     Promise<std::shared_ptr<SocketImpl>> promise;
     evconnlistener* listener;
-    int socket;
+    int_fd socket;
     Option<net::IP> ip;
   };
 
@@ -110,7 +110,7 @@ private:
   // This is a private constructor used by the accept helper
   // functions.
   LibeventSSLSocketImpl(
-      int _s,
+      int_fd _s,
       bufferevent* bev,
       Option<std::string>&& peer_hostname);
 


[5/6] mesos git commit: Windows: Added OpenSSL support in libprocess.

Posted by jo...@apache.org.
Windows: Added OpenSSL support in libprocess.

This patch adds support for building with OpenSSL on Windows. This
requires an installation of OpenSSL, such as 1.0.2L from Shining Light
Productions. Mesos must be configured like:

    -DENABLE_LIBEVENT=ON -DENABLE_SSL=ON
    -DOPENSSL_ROOT_DIR="C:\OpenSSL-Win64"

The use of `_POSIX_HOST_NAME_MAX` was replaced with `MAXHOSTNAMELEN`,
consistent with the rest of libprocess.

Windows does not define `in_addr_t`, but the type as declared by our
cURL dependency for Windows is `unsigned long`.

OpenSSL on Windows requires the adapter module `openssl/applink.c` to
be compiled as part of the consuming project to deal with Windows
runtime library differences. Not doing so manifests itself as the
"no OPENSSL_Applink" runtime error. The OpenSSL FAQ recommends simply
`#include`-ing it in one of the project's source files, e.g.
libprocess's `ssl/utilities.cpp`.

Review: https://reviews.apache.org/r/62511/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/52121064
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/52121064
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/52121064

Branch: refs/heads/master
Commit: 52121064e941b7d980486e5acc5bbd848ce4a460
Parents: f06e618
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Oct 11 14:57:27 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Oct 11 15:03:02 2017 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/ssl/utilities.hpp |  6 ++++++
 3rdparty/libprocess/src/openssl.cpp                   | 13 ++++++++++++-
 3rdparty/libprocess/src/openssl.hpp                   |  6 ++++++
 3rdparty/libprocess/src/ssl/utilities.cpp             |  6 ++++++
 4 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/52121064/3rdparty/libprocess/include/process/ssl/utilities.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/ssl/utilities.hpp b/3rdparty/libprocess/include/process/ssl/utilities.hpp
index 797353c..b7cc31c 100644
--- a/3rdparty/libprocess/include/process/ssl/utilities.hpp
+++ b/3rdparty/libprocess/include/process/ssl/utilities.hpp
@@ -15,6 +15,12 @@
 
 #ifdef USE_SSL_SOCKET
 
+#ifdef __WINDOWS__
+// NOTE: This must be included before the OpenSSL headers as it includes
+// `WinSock2.h` and `Windows.h` in the correct order.
+#include <stout/windows.hpp>
+#endif // __WINDOWS__
+
 #include <openssl/ssl.h>
 #include <openssl/x509.h>
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/52121064/3rdparty/libprocess/src/openssl.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/openssl.cpp b/3rdparty/libprocess/src/openssl.cpp
index d16cc1d..f2fe90b 100644
--- a/3rdparty/libprocess/src/openssl.cpp
+++ b/3rdparty/libprocess/src/openssl.cpp
@@ -12,7 +12,9 @@
 
 #include "openssl.hpp"
 
+#ifndef __WINDOWS__
 #include <sys/param.h>
+#endif // __WINDOWS__
 
 #include <openssl/err.h>
 #include <openssl/rand.h>
@@ -31,6 +33,15 @@
 #include <stout/os.hpp>
 #include <stout/strings.hpp>
 
+#ifdef __WINDOWS__
+// OpenSSL on Windows requires this adapter module to be compiled as part of the
+// consuming project to deal with Windows runtime library differences. Not doing
+// so manifests itself as the "no OPENSSL_Applink" runtime error.
+//
+// https://www.openssl.org/docs/faq.html
+#include <openssl/applink.c>
+#endif // __WINDOWS__
+
 using std::map;
 using std::ostringstream;
 using std::string;
@@ -818,7 +829,7 @@ Try<Nothing> verify(
     X509_NAME* name = X509_get_subject_name(cert);
 
     if (name != nullptr) {
-      char text[_POSIX_HOST_NAME_MAX] {};
+      char text[MAXHOSTNAMELEN] {};
 
       if (X509_NAME_get_text_by_NID(
               name,

http://git-wip-us.apache.org/repos/asf/mesos/blob/52121064/3rdparty/libprocess/src/openssl.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/openssl.hpp b/3rdparty/libprocess/src/openssl.hpp
index e74db5f..0c4192f 100644
--- a/3rdparty/libprocess/src/openssl.hpp
+++ b/3rdparty/libprocess/src/openssl.hpp
@@ -13,6 +13,12 @@
 #ifndef __OPENSSL_HPP__
 #define __OPENSSL_HPP__
 
+#ifdef __WINDOWS__
+// NOTE: This must be included before the OpenSSL headers as it includes
+// `WinSock2.h` and `Windows.h` in the correct order.
+#include <stout/windows.hpp>
+#endif // __WINDOWS__
+
 #include <openssl/ssl.h>
 
 #include <string>

http://git-wip-us.apache.org/repos/asf/mesos/blob/52121064/3rdparty/libprocess/src/ssl/utilities.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/ssl/utilities.cpp b/3rdparty/libprocess/src/ssl/utilities.cpp
index d752acb..9b1d622 100644
--- a/3rdparty/libprocess/src/ssl/utilities.cpp
+++ b/3rdparty/libprocess/src/ssl/utilities.cpp
@@ -248,6 +248,12 @@ Try<X509*> generate_x509(
       return Error("Failed to get IP/4 address");
     }
 
+#ifdef __WINDOWS__
+    // cURL defines `in_addr_t` as `unsigned long` for Windows,
+    // so we do too for consistency.
+    typedef unsigned long in_addr_t;
+#endif // __WINDOWS__
+
     // For `iPAddress` we hand over a binary value as part of the
     // specification.
     if (ASN1_STRING_set(