Skip to content

Commit 41b4baf

Browse files
Fix disk usage logic
1 parent 456c2eb commit 41b4baf

5 files changed

Lines changed: 16 additions & 38 deletions

File tree

client/client_state.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,13 @@ void CLIENT_STATE::show_host_info() {
290290
msg_printf(NULL, MSG_INFO, "- BOINC WSL distro version %d",
291291
wsl.boinc_buda_runner_version
292292
);
293-
double size;
294-
int retval = dir_size_alloc(wd.base_path.c_str(), size);
295-
if (!retval) {
296-
char buf[256];
297-
nbytes_to_string(size, 0, buf, sizeof(buf));
298-
msg_printf(NULL, MSG_INFO, "- Disk usage: %s", buf);
293+
if (!wsl.base_path.empty()) {
294+
double size;
295+
int retval = dir_size_alloc(wsl.base_path.c_str(), size);
296+
if (!retval) {
297+
nbytes_to_string(size, 0, buf, sizeof(buf));
298+
msg_printf(NULL, MSG_INFO, "- Disk usage: %s", buf);
299+
}
299300
}
300301
}
301302
}

client/cpu_sched.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ static void promote_multi_thread_jobs(vector<RESULT*>& runnable_jobs) {
10701070
// return true if r0 is more important to run than r1
10711071
//
10721072
static inline bool more_important(RESULT* r0, RESULT* r1) {
1073-
bool cp0, cp1;
1073+
bool cp0=false, cp1;
10741074

10751075
if (cc_config.prioritize_gpu) {
10761076
cp0 = r0->uses_coprocs();

client/cs_prefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ int CLIENT_STATE::get_disk_usages() {
122122
//
123123
WSL_DISTRO *wd = host_info.wsl_distros.find_docker();
124124
if (wd) {
125-
retval = dir_size_alloc(wd.base_path.c_str(), size);
125+
retval = dir_size_alloc(wd->base_path.c_str(), size);
126126
if (!retval) {
127-
client_disk_usage = size;
127+
client_disk_usage += size;
128128
total_disk_usage += size;
129129
}
130130
}

client/gui_rpc_server_ops.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ static void handle_get_project_status(GUI_RPC_CONN& grc) {
148148
}
149149

150150
static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
151-
double size, boinc_non_project, d_allowed;
152-
// double boinc_total;
153-
154151
grc.mfout.printf("<disk_usage_summary>\n");
155152
int retval = get_filesystem_info(
156153
gstate.host_info.d_total, gstate.host_info.d_free
@@ -161,27 +158,6 @@ static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
161158
);
162159
}
163160

164-
dir_size_alloc(".", boinc_non_project, false);
165-
dir_size_alloc("locale", size, false);
166-
boinc_non_project += size;
167-
#ifdef __APPLE__
168-
if (gstate.launched_by_manager) {
169-
// If launched by Manager, get Manager's size on disk
170-
char path[MAXPATHLEN];
171-
double manager_size = 0.0;
172-
OSStatus err = noErr;
173-
174-
retval = proc_pidpath(getppid(), path, sizeof(path));
175-
if (retval <= 0) {
176-
err = fnfErr;
177-
}
178-
if (!err) {
179-
dir_size_alloc(path, manager_size, true);
180-
boinc_non_project += manager_size;
181-
}
182-
}
183-
#endif
184-
// boinc_total = boinc_non_project;
185161
gstate.get_disk_usages();
186162
for (PROJECT* p: gstate.projects) {
187163
grc.mfout.printf(
@@ -191,17 +167,16 @@ static void handle_get_disk_usage(GUI_RPC_CONN& grc) {
191167
"</project>\n",
192168
p->master_url, p->disk_usage
193169
);
194-
// boinc_total += p->disk_usage;
195170
}
196-
d_allowed = gstate.allowed_disk_usage(gstate.total_disk_usage);
171+
double d_allowed = gstate.allowed_disk_usage(gstate.total_disk_usage);
197172
grc.mfout.printf(
198173
"<d_total>%f</d_total>\n"
199174
"<d_free>%f</d_free>\n"
200175
"<d_boinc>%f</d_boinc>\n"
201176
"<d_allowed>%f</d_allowed>\n",
202177
gstate.host_info.d_total,
203178
gstate.host_info.d_free,
204-
boinc_non_project,
179+
gstate.client_disk_usage,
205180
d_allowed
206181
);
207182
grc.mfout.printf("</disk_usage_summary>\n");

client/hostinfo_wsl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ int get_all_distros(WSL_DISTROS& distros) {
130130

131131
// if BOINC distro, get its data dir so we can find disk usage
132132
//
133+
char path[256];
134+
DWORD path_len = sizeof(path);
133135
if (distro.distro_name == BOINC_WSL_DISTRO_NAME) {
134136
ret = RegQueryValueEx(hSubKey, "BasePath", NULL, NULL,
135-
(LPBYTE)wsl_name, &wsl_name_len
137+
(LPBYTE)path, &path_len
136138
);
137139
if (ret == ERROR_SUCCESS) {
138-
distro.base_path = wsl_name;
140+
distro.base_path = path;
139141
}
140142
}
141143

0 commit comments

Comments
 (0)