Skip to content

Commit

Permalink
small fixes and renamings
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Koshura <[email protected]>
  • Loading branch information
AenBleidd committed Aug 18, 2024
1 parent 21814a9 commit 0a354f5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
28 changes: 14 additions & 14 deletions client/client_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void CLIENT_STATE::show_host_info() {

#ifdef _WIN64
if (host_info.wsl_available) {
msg_printf(NULL, MSG_INFO, "WSL detected:");
msg_printf(NULL, MSG_INFO, "WSL present:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_default) {
Expand All @@ -262,7 +262,7 @@ void CLIENT_STATE::show_host_info() {
}
}
} else {
msg_printf(NULL, MSG_INFO, "WSL is not found or not allowed to be used. For more details see https://github.com/BOINC/boinc/wiki/Client-configuration");
msg_printf(NULL, MSG_INFO, "WSL is not present or is not allowed by configuration file. For more details see https://github.com/BOINC/boinc/wiki/Client-configuration");
}
#endif

Expand All @@ -280,37 +280,37 @@ void CLIENT_STATE::show_host_info() {
}
#endif
}
#ifndef _WIN64
if (host_info.docker_available && strlen(host_info.docker_version)) {
msg_printf(NULL, MSG_INFO, "Docker %s is installed and available", host_info.docker_version);
#else
#ifdef _WIN64
if (host_info.docker_available) {
msg_printf(NULL, MSG_INFO, "Docker is installed and available on next WSLs:");
msg_printf(NULL, MSG_INFO, "Docker is present on next WSLs:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_docker_available) {
msg_printf(NULL, MSG_INFO, " [%s]: Docker version is: %s", wsl.distro_name.c_str(), wsl.docker_version.c_str());
}
}
#else
if (host_info.docker_available && strlen(host_info.docker_version)) {
msg_printf(NULL, MSG_INFO, "Docker %s is present", host_info.docker_version);
#endif
} else {
msg_printf(NULL, MSG_INFO, "Docker is not installed or is not available for running task");
msg_printf(NULL, MSG_INFO, "Docker is not present");
}
#ifndef _WIN64
if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) {
msg_printf(NULL, MSG_INFO, "Docker compose %s is installed and available", host_info.docker_compose_version);
#else
#ifdef _WIN64
if (host_info.docker_compose_available) {
msg_printf(NULL, MSG_INFO, "Docker compose is installed and available on next WSLs:");
msg_printf(NULL, MSG_INFO, "Docker compose is present on next WSLs:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_docker_compose_available) {
msg_printf(NULL, MSG_INFO, " [%s]: Docker compose version is: %s", wsl.distro_name.c_str(), wsl.docker_compose_version.c_str());
}
}
#else
if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) {
msg_printf(NULL, MSG_INFO, "Docker compose %s is present", host_info.docker_compose_version);
#endif
} else {
msg_printf(NULL, MSG_INFO, "Docker compose is not installed or is not available for running task");
msg_printf(NULL, MSG_INFO, "Docker compose is not present");
}
}

Expand Down
20 changes: 10 additions & 10 deletions client/hostinfo_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,9 @@ int HOST_INFO::get_virtualbox_version() {
return 0;
}

//check if docker compose or docker-compose is installed on volunteer's host
//
int HOST_INFO::get_docker_compose_info(){
// check if docker compose is installed on volunteer's host
// populates docker compose version and docker_compose_available on success
bool HOST_INFO::get_docker_compose_info(){
FILE* f = popen(command_get_docker_compose_version, "r");
if (f) {
char buf[256];
Expand All @@ -1246,15 +1246,15 @@ int HOST_INFO::get_docker_compose_info(){
safe_strcpy(docker_compose_version, version.c_str());
}
pclose(f);
return 0;
return true;
}
return 1;
return false;
}


//check if docker is installed on volunteer's host
//
int HOST_INFO::get_docker_info(){
// check if docker is installed on volunteer's host
// populates docker version and docker_available on success
bool HOST_INFO::get_docker_info(){
FILE* f = popen(command_get_docker_version, "r");
if (f) {
char buf[256];
Expand All @@ -1265,9 +1265,9 @@ int HOST_INFO::get_docker_info(){
safe_strcpy(docker_version, version.c_str());
}
pclose(f);
return 0;
return true;
}
return 1;
return false;
}


Expand Down
17 changes: 8 additions & 9 deletions client/hostinfo_wsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ bool get_available_wsls(std::vector<std::pair<std::string, DWORD>>& wsls, std::s

typedef HRESULT(WINAPI *PWslLaunch)(PCWSTR, PCWSTR, BOOL, HANDLE, HANDLE, HANDLE, HANDLE*);

struct resource_helper {
public:
struct WSL_RESOURCE_MANAGER {
HINSTANCE wsl_lib = NULL;
HANDLE in_read = NULL;
HANDLE in_write = NULL;
HANDLE out_read = NULL;
HANDLE out_write = NULL;
PWslLaunch pWslLaunch = NULL;

~resource_helper() {
~WSL_RESOURCE_MANAGER() {
close_handle(in_read);
close_handle(in_write);
close_handle(out_read);
Expand Down Expand Up @@ -180,7 +179,7 @@ std::wstring s2ws(const std::string& s)
return r;
}

bool create_wsl_process(const resource_helper& rs, const std::string& wsl_distro_name, const std::string& command, HANDLE* handle, bool use_current_work_dir = false) {
bool create_wsl_process(const WSL_RESOURCE_MANAGER& rs, const std::string& wsl_distro_name, const std::string& command, HANDLE* handle, bool use_current_work_dir = false) {
return (rs.pWslLaunch(s2ws(wsl_distro_name).c_str(), s2ws(command).c_str(), use_current_work_dir, rs.in_read, rs.out_write, rs.out_write, handle) == S_OK);
}

Expand Down Expand Up @@ -262,18 +261,18 @@ void parse_sysctl_output(const std::vector<std::string>& lines, std::string& ost

// Returns the OS name and version for WSL when enabled
//
int get_wsl_information(std::vector<std::string> allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available) {
bool get_wsl_information(std::vector<std::string> allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available) {
std::vector<std::pair<std::string, DWORD>> distros;
std::string default_distro;

if (!get_available_wsls(distros, default_distro)) {
return 1;
return false;
}

resource_helper rs;
WSL_RESOURCE_MANAGER rs;

if (rs.prepare_resources()) {
return 1;
return false;
}

wsl_available = false;
Expand Down Expand Up @@ -410,7 +409,7 @@ int get_wsl_information(std::vector<std::string> allowed_wsls, bool& wsl_availab
wsls.wsls.push_back(wsl);
}

return 0;
return true;
}

#endif // _WIN64
6 changes: 3 additions & 3 deletions lib/hostinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class HOST_INFO {
// that is why it makes no sense to have this information put here
// instead the information about the available 'docker' and 'docker compose'
// installations should be taken from every particular WSL distro
int get_docker_info();
int get_docker_compose_info();
bool get_docker_info();
bool get_docker_compose_info();
#endif
void make_random_string(const char* salt, char* out);
void generate_host_cpid();
Expand Down Expand Up @@ -172,7 +172,7 @@ class HOST_INFO {
extern void make_secure_random_string(char*);

#ifdef _WIN64
extern int get_wsl_information(std::vector<std::string> allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available);
extern bool get_wsl_information(std::vector<std::string> allowed_wsls, bool& wsl_available, WSLS& wsls, bool detect_docker, bool& docker_available, bool& docker_compose_available);
extern int get_processor_group(HANDLE);
#endif

Expand Down

0 comments on commit 0a354f5

Please sign in to comment.