diff --git a/checkin_notes b/checkin_notes index bdfd97b2c9..d1dd197234 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9628,3 +9628,17 @@ Rom 28 Dec 2011 client/ hostinfo_unix.cpp + +David 28 Dec 2011 + - client: shuffle disk usage code in preparation for disk accounting + - use new XML parser in some GUI RPC code + + lib/ + gui_rpc_client_ops.cpp + gui_rpc_client.h + client/ + client_types.h + client_state.h + gui_rpc_server_ops.cpp + cs_prefs.cpp + cs_scheduler.cpp diff --git a/client/client_state.h b/client/client_state.h index 41296215ae..c7a24211d0 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -375,9 +375,11 @@ struct CLIENT_STATE { bool is_supported_platform(const char*); // --------------- cs_prefs.cpp: - int project_disk_usage(PROJECT*, double&); - int total_disk_usage(double&); - // returns the total disk usage of BOINC on this host + double client_disk_usage; + // disk usage not counting projects + // computed by get_disk_usages() + double total_disk_usage; + int get_disk_usages(); double allowed_disk_usage(double boinc_total); int allowed_project_disk_usage(double&); int suspend_tasks(int reason); diff --git a/client/client_types.h b/client/client_types.h index 31a9bef955..067c2d4014 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -359,6 +359,8 @@ struct PROJECT : PROJ_AM { // to make sure they haven't been tampered with. // This provides only the illusion of security. bool use_symlinks; + double disk_usage; + // computed by get_disk_usages() // items send in scheduler replies, requesting that // various things be sent in the next request diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index f552d2cccc..f6248f61aa 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -67,29 +67,47 @@ double CLIENT_STATE::allowed_disk_usage(double boinc_total) { #ifndef SIM -int CLIENT_STATE::project_disk_usage(PROJECT* p, double& size) { +// populate: +// PROJECT::disk_usage for all projects +// GLOBAL_STATE::client_disk_usage +// GLOBAL_STATE::total_disk_usage +// +int CLIENT_STATE::get_disk_usages() { char buf[256]; unsigned int i; - double s; + double size; + PROJECT* p; + int retval; - get_project_dir(p, buf, sizeof(buf)); - dir_size(buf, size); + client_disk_usage = 0; + total_disk_usage = 0; + for (i=0; idisk_usage = 0; + get_project_dir(p, buf, sizeof(buf)); + retval = dir_size(buf, size); + if (!retval) p->disk_usage = size; + } for (i=0; iwup->project != p) continue; get_slot_dir(atp->slot, buf, sizeof(buf)); - dir_size(buf, s); - size += s; + retval = dir_size(buf, size); + if (retval) continue; + atp->wup->project->disk_usage += size; + } + for (i=0; idisk_usage; + } + retval = dir_size(".", size, false); + if (!retval) { + client_disk_usage = size; + total_disk_usage += size; } - return 0; } -int CLIENT_STATE::total_disk_usage(double& size) { - return dir_size(".", size); -} - // See if we should suspend processing // int CLIENT_STATE::check_suspend_processing() { @@ -453,12 +471,11 @@ void CLIENT_STATE::read_global_prefs( " max memory usage when idle: %.2fMB", (host_info.m_nbytes*global_prefs.ram_max_used_idle_frac)/MEGA ); - double x; #ifndef SIM - total_disk_usage(x); + get_disk_usages(); msg_printf(NULL, MSG_INFO, " max disk usage: %.2fGB", - allowed_disk_usage(x)/GIGA + allowed_disk_usage(total_disk_usage)/GIGA ); #endif // max_cpus, bandwidth limits may have changed diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp index d4d7b09e87..f565fce9fd 100644 --- a/client/cs_scheduler.cpp +++ b/client/cs_scheduler.cpp @@ -74,7 +74,6 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) { MIOFILE mf; unsigned int i; RESULT* rp; - double disk_total, disk_project; get_sched_request_filename(*p, buf, sizeof(buf)); FILE* f = boinc_fopen(buf, "wb"); @@ -209,14 +208,13 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) { // get and write disk usage // - total_disk_usage(disk_total); - project_disk_usage(p, disk_project); + get_disk_usages(); fprintf(f, " \n" " %f\n" " %f\n" " \n", - disk_total, disk_project + total_disk_usage, p->disk_usage ); // copy request values from RSC_WORK_FETCH to COPROC @@ -797,6 +795,8 @@ int CLIENT_STATE::handle_scheduler_reply(PROJECT* project, char* scheduler_url) strcpy(avp->cmdline, avpp.cmdline); avp->gpu_usage = avpp.gpu_usage; strlcpy(avp->api_version, avpp.api_version, sizeof(avp->api_version)); + avp->dont_throttle = avpp.dont_throttle; + avp->needs_network = avpp.needs_network; // if we had download failures, clear them // diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index 014a67d1a7..0bcb38618b 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -155,19 +155,19 @@ static void handle_get_disk_usage(GUI_RPC_CONN& grc) { } #endif boinc_total = boinc_non_project; + gstate.get_disk_usages(); for (i=0; i\n" " %s\n" " %f\n" "\n", - p->master_url, size + p->master_url, p->disk_usage ); - boinc_total += size; + boinc_total += p->disk_usage; } - d_allowed = gstate.allowed_disk_usage(boinc_total); + d_allowed = gstate.allowed_disk_usage(gstate.total_disk_usage); grc.mfout.printf( "%f\n" "%f\n" diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 120bcd965e..2e088538e1 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -209,7 +209,7 @@ public: ~APP_VERSION(); int parse(XML_PARSER&); - int parse_coproc(MIOFILE&); + int parse_coproc(XML_PARSER&); void print(); void clear(); }; diff --git a/lib/gui_rpc_client_ops.cpp b/lib/gui_rpc_client_ops.cpp index 9b06dcf132..ce37f98d60 100644 --- a/lib/gui_rpc_client_ops.cpp +++ b/lib/gui_rpc_client_ops.cpp @@ -100,14 +100,13 @@ int DAILY_XFER_HISTORY::parse(XML_PARSER& xp) { } int GUI_URL::parse(XML_PARSER& xp) { - char buf[256]; - MIOFILE& in = *(xp.f); - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) return 0; - if (match_tag(buf, "")) break; - if (parse_str(buf, "", name)) continue; - if (parse_str(buf, "", description)) continue; - if (parse_str(buf, "", url)) continue; + while (!xp.get_tag()) { + if (!xp.is_tag) continue; + if (xp.match_tag("/gui_url")) return 0; + if (xp.match_tag("/gui_urls")) break; + if (xp.parse_string("name", name)) continue; + if (xp.parse_string("description", description)) continue; + if (xp.parse_string("url", url)) continue; } return ERR_XML_PARSE; } @@ -246,57 +245,55 @@ void PROJECT::get_name(std::string& s) { } int PROJECT::parse(XML_PARSER& xp) { - char buf[256]; int retval; - MIOFILE& in = *(xp.f); - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) return 0; - if (parse_str(buf, "", master_url, sizeof(master_url))) continue; - if (parse_double(buf, "", resource_share)) continue; - if (parse_str(buf, "", project_name)) continue; - if (parse_str(buf, "", user_name)) { + while (!xp.get_tag()) { + if (xp.match_tag("/project")) return 0; + if (xp.parse_str("master_url", master_url, sizeof(master_url))) continue; + if (xp.parse_double("resource_share", resource_share)) continue; + if (xp.parse_string("project_name", project_name)) continue; + if (xp.parse_string("user_name", user_name)) { xml_unescape(user_name); continue; } - if (parse_str(buf, "", team_name)) { + if (xp.parse_string("team_name", team_name)) { xml_unescape(team_name); continue; } - if (parse_int(buf, "", hostid)) continue; - if (parse_double(buf, "", user_total_credit)) continue; - if (parse_double(buf, "", user_expavg_credit)) continue; - if (parse_double(buf, "", host_total_credit)) continue; - if (parse_double(buf, "", host_expavg_credit)) continue; - if (parse_double(buf, "", disk_usage)) continue; - if (parse_int(buf, "", nrpc_failures)) continue; - if (parse_int(buf, "", master_fetch_failures)) continue; - if (parse_double(buf, "", min_rpc_time)) continue; - if (parse_double(buf, "", download_backoff)) continue; - if (parse_double(buf, "", upload_backoff)) continue; - if (parse_double(buf, "", sched_priority)) continue; - if (parse_double(buf, "", cpu_backoff_time)) continue; - if (parse_double(buf, "", cpu_backoff_interval)) continue; - if (parse_double(buf, "", cuda_backoff_time)) continue; - if (parse_double(buf, "", cuda_backoff_interval)) continue; - if (parse_double(buf, "", ati_backoff_time)) continue; - if (parse_double(buf, "", ati_backoff_interval)) continue; - if (parse_double(buf, "", duration_correction_factor)) continue; - if (parse_bool(buf, "anonymous_platform", anonymous_platform)) continue; - if (parse_bool(buf, "master_url_fetch_pending", master_url_fetch_pending)) continue; - if (parse_int(buf, "", sched_rpc_pending)) continue; - if (parse_bool(buf, "non_cpu_intensive", non_cpu_intensive)) continue; - if (parse_bool(buf, "suspended_via_gui", suspended_via_gui)) continue; - if (parse_bool(buf, "dont_request_more_work", dont_request_more_work)) continue; - if (parse_bool(buf, "ended", ended)) continue; - if (parse_bool(buf, "scheduler_rpc_in_progress", scheduler_rpc_in_progress)) continue; - if (parse_bool(buf, "attached_via_acct_mgr", attached_via_acct_mgr)) continue; - if (parse_bool(buf, "detach_when_done", detach_when_done)) continue; - if (parse_bool(buf, "trickle_up_pending", trickle_up_pending)) continue; - if (match_tag(buf, "")) { - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) break; - if (match_tag(buf, "")) { + if (xp.parse_int("hostid", hostid)) continue; + if (xp.parse_double("user_total_credit", user_total_credit)) continue; + if (xp.parse_double("user_expavg_credit", user_expavg_credit)) continue; + if (xp.parse_double("host_total_credit", host_total_credit)) continue; + if (xp.parse_double("host_expavg_credit", host_expavg_credit)) continue; + if (xp.parse_double("disk_usage", disk_usage)) continue; + if (xp.parse_int("nrpc_failures", nrpc_failures)) continue; + if (xp.parse_int("master_fetch_failures", master_fetch_failures)) continue; + if (xp.parse_double("min_rpc_time", min_rpc_time)) continue; + if (xp.parse_double("download_backoff", download_backoff)) continue; + if (xp.parse_double("upload_backoff", upload_backoff)) continue; + if (xp.parse_double("sched_priority", sched_priority)) continue; + if (xp.parse_double("cpu_backoff_time", cpu_backoff_time)) continue; + if (xp.parse_double("cpu_backoff_interval", cpu_backoff_interval)) continue; + if (xp.parse_double("cuda_backoff_time", cuda_backoff_time)) continue; + if (xp.parse_double("cuda_backoff_interval", cuda_backoff_interval)) continue; + if (xp.parse_double("ati_backoff_time", ati_backoff_time)) continue; + if (xp.parse_double("ati_backoff_interval", ati_backoff_interval)) continue; + if (xp.parse_double("duration_correction_factor", duration_correction_factor)) continue; + if (xp.parse_bool("anonymous_platform", anonymous_platform)) continue; + if (xp.parse_bool("master_url_fetch_pending", master_url_fetch_pending)) continue; + if (xp.parse_int("sched_rpc_pending", sched_rpc_pending)) continue; + if (xp.parse_bool("non_cpu_intensive", non_cpu_intensive)) continue; + if (xp.parse_bool("suspended_via_gui", suspended_via_gui)) continue; + if (xp.parse_bool("dont_request_more_work", dont_request_more_work)) continue; + if (xp.parse_bool("ended", ended)) continue; + if (xp.parse_bool("scheduler_rpc_in_progress", scheduler_rpc_in_progress)) continue; + if (xp.parse_bool("attached_via_acct_mgr", attached_via_acct_mgr)) continue; + if (xp.parse_bool("detach_when_done", detach_when_done)) continue; + if (xp.parse_bool("trickle_up_pending", trickle_up_pending)) continue; + if (xp.match_tag("gui_urls")) { + while (!xp.get_tag()) { + if (xp.match_tag("/gui_urls")) break; + if (xp.match_tag("gui_url")) { GUI_URL gu; retval = gu.parse(xp); if (retval) break; @@ -306,12 +303,12 @@ int PROJECT::parse(XML_PARSER& xp) { } continue; } - if (parse_double(buf, "", project_files_downloaded_time)) continue; - if (parse_double(buf, "", last_rpc_time)) continue; - if (parse_bool(buf, "no_cpu_pref", no_cpu_pref)) continue; - if (parse_bool(buf, "no_cuda_pref", no_cuda_pref)) continue; - if (parse_bool(buf, "no_ati_pref", no_ati_pref)) continue; - if (parse_str(buf, "venue", venue, sizeof(venue))) continue; + if (xp.parse_double("project_files_downloaded_time", project_files_downloaded_time)) continue; + if (xp.parse_double("last_rpc_time", last_rpc_time)) continue; + if (xp.parse_bool("no_cpu_pref", no_cpu_pref)) continue; + if (xp.parse_bool("no_cuda_pref", no_cuda_pref)) continue; + if (xp.parse_bool("no_ati_pref", no_ati_pref)) continue; + if (xp.parse_str("venue", venue, sizeof(venue))) continue; } return ERR_XML_PARSE; } @@ -369,12 +366,10 @@ APP::~APP() { } int APP::parse(XML_PARSER& xp) { - char buf[256]; - MIOFILE& in = *(xp.f); - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) return 0; - if (parse_str(buf, "", name, sizeof(name))) continue; - if (parse_str(buf, "", user_friendly_name, sizeof(user_friendly_name))) continue; + while (!xp.get_tag()) { + if (xp.match_tag("/app")) return 0; + if (xp.parse_str("name", name, sizeof(name))) continue; + if (xp.parse_str("user_friendly_name", user_friendly_name, sizeof(user_friendly_name))) continue; } return ERR_XML_PARSE; } @@ -393,12 +388,12 @@ APP_VERSION::~APP_VERSION() { clear(); } -int APP_VERSION::parse_coproc(MIOFILE& in) { - char buf[256], type_buf[256]; +int APP_VERSION::parse_coproc(XML_PARSER& xp) { + char type_buf[256]; double count = 0; - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) { + while (!xp.get_tag()) { + if (xp.match_tag("/coproc")) { if (!strcmp(type_buf, "CUDA")) { ncudas = count; } else if (!strcmp(type_buf, GPU_TYPE_ATI)) { @@ -406,26 +401,24 @@ int APP_VERSION::parse_coproc(MIOFILE& in) { } return 0; } - if (parse_str(buf, "", type_buf, sizeof(type_buf))) continue; - if (parse_double(buf, "", count)) continue; + if (xp.parse_str("type", type_buf, sizeof(type_buf))) continue; + if (xp.parse_double("count", count)) continue; } return ERR_XML_PARSE; } int APP_VERSION::parse(XML_PARSER& xp) { - char buf[256]; - MIOFILE& in = *(xp.f); - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) return 0; - if (parse_str(buf, "", app_name, sizeof(app_name))) continue; - if (parse_int(buf, "", version_num)) continue; - if (parse_str(buf, "", plan_class, sizeof(plan_class))) continue; - if (parse_str(buf, "", platform, sizeof(platform))) continue; - if (parse_double(buf, "", avg_ncpus)) continue; - if (parse_double(buf, "", gpu_ram)) continue; - if (parse_double(buf, "", flops)) continue; - if (match_tag(buf, "")) { - parse_coproc(in); + while (!xp.get_tag()) { + if (xp.match_tag("/app_version")) return 0; + if (xp.parse_str("app_name", app_name, sizeof(app_name))) continue; + if (xp.parse_int("version_num", version_num)) continue; + if (xp.parse_str("plan_class", plan_class, sizeof(plan_class))) continue; + if (xp.parse_str("platform", platform, sizeof(platform))) continue; + if (xp.parse_double("avg_ncpus", avg_ncpus)) continue; + if (xp.parse_double("gpu_ram", gpu_ram)) continue; + if (xp.parse_double("flops", flops)) continue; + if (xp.match_tag("coproc")) { + parse_coproc(xp); continue; } } @@ -445,17 +438,15 @@ WORKUNIT::~WORKUNIT() { } int WORKUNIT::parse(XML_PARSER& xp) { - char buf[256]; - MIOFILE& in = *(xp.f); - while (in.fgets(buf, 256)) { - if (match_tag(buf, "")) return 0; - if (parse_str(buf, "", name, sizeof(name))) continue; - if (parse_str(buf, "", app_name, sizeof(app_name))) continue; - if (parse_int(buf, "", version_num)) continue; - if (parse_double(buf, "", rsc_fpops_est)) continue; - if (parse_double(buf, "", rsc_fpops_bound)) continue; - if (parse_double(buf, "", rsc_memory_bound)) continue; - if (parse_double(buf, "", rsc_disk_bound)) continue; + while (!xp.get_tag()) { + if (xp.match_tag("/workunit")) return 0; + if (xp.parse_str("name", name, sizeof(name))) continue; + if (xp.parse_str("app_name", app_name, sizeof(app_name))) continue; + if (xp.parse_int("version_num", version_num)) continue; + if (xp.parse_double("rsc_fpops_est", rsc_fpops_est)) continue; + if (xp.parse_double("rsc_fpops_bound", rsc_fpops_bound)) continue; + if (xp.parse_double("rsc_memory_bound", rsc_memory_bound)) continue; + if (xp.parse_double("rsc_disk_bound", rsc_disk_bound)) continue; } return ERR_XML_PARSE; }