]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: verify unix sockets support on Windows
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 20 Aug 2020 10:24:23 +0000 (10:24 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 28 Oct 2020 09:55:20 +0000 (09:55 +0000)
Windows Server 2016 doesn't support unix sockets. We'll
check the Windows version and log a message (but not at
error level) when attempting to initialize the admin socket.

This will prevent the following error from being printed
whenever mapping RBD images:

  AdminSocketConfigObs::init: failed: AdminSocket::bind_and_listen:
  failed to bind the UNIX domain socket to
  'C:/ProgramData/Ceph/out/client.admin.2560.asok':
  (10050) Unknown error

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/common/admin_socket.cc
src/include/util.h

index 328a9f1ae8a5c3c7f5c1e3324e604501362982b7..01021d94193bf10034828f61a2196b2b61ad5fa8 100644 (file)
@@ -694,6 +694,19 @@ bool AdminSocket::init(const std::string& path)
 {
   ldout(m_cct, 5) << "init " << path << dendl;
 
+  #ifdef _WIN32
+  OSVERSIONINFOEXW ver = {0};
+  ver.dwOSVersionInfoSize = sizeof(ver);
+  get_windows_version(&ver);
+
+  if (std::tie(ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber) <
+      std::make_tuple(10, 0, 17063)) {
+    ldout(m_cct, 5) << "Unix sockets require Windows 10.0.17063 or later. "
+                    << "The admin socket will not be available." << dendl;
+    return false;
+  }
+  #endif
+
   /* Set up things for the new thread */
   std::string err;
   int pipe_rd = -1, pipe_wr = -1;
index e8b9861e9e5bd531338ad85a9c3f5665aab35dcd..acad4a52c9f9fde51bfa05cfe00b4d9bf0689c9c 100644 (file)
@@ -79,6 +79,11 @@ int get_cgroup_memory_limit(uint64_t *limit);
 /// collect info from @p uname(2), @p /proc/meminfo and @p /proc/cpuinfo
 void collect_sys_info(std::map<std::string, std::string> *m, CephContext *cct);
 
+#ifdef _WIN32
+/// Retrieve the actual Windows version, regardless of the app manifest.
+int get_windows_version(POSVERSIONINFOEXW ver);
+#endif
+
 /// dump service ids grouped by their host to the specified formatter
 /// @param f formatter for the output
 /// @param services a map from hostname to a list of service id hosted by this host