From: Lucian Petrut Date: Thu, 20 Aug 2020 10:24:23 +0000 (+0000) Subject: common: verify unix sockets support on Windows X-Git-Tag: v16.1.0~652^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=948ffd48ab22a60fdfe174c57339c8647dbf7002;p=ceph.git common: verify unix sockets support on Windows 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 --- diff --git a/src/common/admin_socket.cc b/src/common/admin_socket.cc index 328a9f1ae8a..01021d94193 100644 --- a/src/common/admin_socket.cc +++ b/src/common/admin_socket.cc @@ -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; diff --git a/src/include/util.h b/src/include/util.h index e8b9861e9e5..acad4a52c9f 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -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 *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