| 1071 | }; |
| 1072 | |
| 1073 | bool AdminSocket::init(const std::string& path) |
| 1074 | { |
| 1075 | ldout(m_cct, 5) << "init " << path << dendl; |
| 1076 | |
| 1077 | #ifdef _WIN32 |
| 1078 | OSVERSIONINFOEXW ver = {0}; |
| 1079 | ver.dwOSVersionInfoSize = sizeof(ver); |
| 1080 | get_windows_version(&ver); |
| 1081 | |
| 1082 | if (std::tie(ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber) < |
| 1083 | std::make_tuple(10, 0, 17063)) { |
| 1084 | ldout(m_cct, 5) << "Unix sockets require Windows 10.0.17063 or later. " |
| 1085 | << "The admin socket will not be available." << dendl; |
| 1086 | return false; |
| 1087 | } |
| 1088 | #endif |
| 1089 | |
| 1090 | /* Set up things for the new thread */ |
| 1091 | std::string err; |
| 1092 | int pipe_rd = -1, pipe_wr = -1; |
| 1093 | err = create_wakeup_pipe(&pipe_rd, &pipe_wr); |
| 1094 | if (!err.empty()) { |
| 1095 | lderr(m_cct) << "AdminSocketConfigObs::init: error: " << err << dendl; |
| 1096 | return false; |
| 1097 | } |
| 1098 | int sock_fd; |
| 1099 | err = bind_and_listen(path, &sock_fd); |
| 1100 | if (!err.empty()) { |
| 1101 | lderr(m_cct) << "AdminSocketConfigObs::init: failed: " << err << dendl; |
| 1102 | close(pipe_rd); |
| 1103 | close(pipe_wr); |
| 1104 | return false; |
| 1105 | } |
| 1106 | |
| 1107 | /* Create new thread */ |
| 1108 | m_sock_fd = sock_fd; |
| 1109 | m_wakeup_rd_fd = pipe_rd; |
| 1110 | m_wakeup_wr_fd = pipe_wr; |
| 1111 | m_path = path; |
| 1112 | |
| 1113 | version_hook = std::make_unique<VersionHook>(); |
| 1114 | register_command("0", version_hook.get(), ""); |
| 1115 | register_command("version", version_hook.get(), "get ceph version"); |
| 1116 | register_command("git_version", version_hook.get(), |
| 1117 | "get git sha1"); |
| 1118 | help_hook = std::make_unique<HelpHook>(this); |
| 1119 | register_command("help", help_hook.get(), |
| 1120 | "list available commands"); |
| 1121 | getdescs_hook = std::make_unique<GetdescsHook>(this); |
| 1122 | register_command("get_command_descriptions", |
| 1123 | getdescs_hook.get(), "list available commands"); |
| 1124 | |
| 1125 | raise_hook = std::make_unique<RaiseHook>(m_cct); |
| 1126 | register_command( |
| 1127 | RaiseHook::get_cmddesc(), |
| 1128 | raise_hook.get(), |
| 1129 | RaiseHook::get_help()); |
| 1130 |
nothing calls this directly
no test coverage detected