From 18983d42e1ae9c2ba5be8bf0d43a90b70a0e3d6d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 22 Jan 2004 19:30:42 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2922 --- checkin_notes | 19 +++++++ client/app.C | 8 ++- client/client_state.h | 1 + client/cs_scheduler.C | 4 +- client/cs_statefile.C | 18 +++++-- client/gui_rpc_client.C | 111 ++-------------------------------------- client/gui_rpc_client.h | 4 +- client/gui_rpc_server.C | 15 +----- client/gui_test.C | 7 +-- 9 files changed, 50 insertions(+), 137 deletions(-) diff --git a/checkin_notes b/checkin_notes index c78d06e716..745b534925 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9499,3 +9499,22 @@ David Jan 22 2004 lib/ util.C,h xml_util.C,h + +David Jan 22 2004 + - change the GUI RPC protocol so that there's a single + request that returns the entire state + (same contents as the client state file) + - add fraction_done, current_cpu_time to output + - factored out CLIENT_STATE::write_state(FILE*) + (used for both state file write and GUI RPC) + - always copy team name from scheduler reply + (so that we'll learn if user quits team) + + client/ + app.C + client_state.h + cs_scheduler.C + cs_statefile.C + gui_rpc_client.C,h + gui_rpc_server.C + gui_test.C diff --git a/client/app.C b/client/app.C index 9546bf90b8..68b3dc852c 100644 --- a/client/app.C +++ b/client/app.C @@ -1256,12 +1256,16 @@ int ACTIVE_TASK::write(FILE* fout) { " %d\n" " %d\n" " %f\n" + " %f\n" + " %f\n" "\n", result->project->master_url, result->name, app_version->version_num, slot, - checkpoint_cpu_time + checkpoint_cpu_time, + fraction_done, + current_cpu_time ); return 0; } @@ -1324,6 +1328,8 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) { else if (parse_int(buf, "", app_version_num)) continue; else if (parse_int(buf, "", slot)) continue; else if (parse_double(buf, "", checkpoint_cpu_time)) continue; + else if (parse_double(buf, "", fraction_done)) continue; + else if (parse_double(buf, "", current_cpu_time)) continue; else msg_printf(NULL, MSG_ERROR, "ACTIVE_TASK::parse(): unrecognized %s\n", buf); } return ERR_XML_PARSE; diff --git a/client/client_state.h b/client/client_state.h index 54ef3a8ae3..6d2bd1dbe6 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -258,6 +258,7 @@ private: public: void set_client_state_dirty(char*); int parse_state_file(); + int write_state(FILE*); int write_state_file(); int write_state_file_if_needed(); int parse_venue(); diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 63d3cab8ee..bca326dbe2 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -485,9 +485,7 @@ int CLIENT_STATE::handle_scheduler_reply( if (strlen(sr.user_name)) { safe_strcpy(project->user_name, sr.user_name); } - if (strlen(sr.team_name)) { - safe_strcpy(project->team_name, sr.team_name); - } + safe_strcpy(project->team_name, sr.team_name); project->user_total_credit = sr.user_total_credit; project->user_expavg_credit = sr.user_expavg_credit; project->user_create_time = sr.user_create_time; diff --git a/client/cs_statefile.C b/client/cs_statefile.C index f15897df1c..24aea619c5 100644 --- a/client/cs_statefile.C +++ b/client/cs_statefile.C @@ -185,7 +185,6 @@ int CLIENT_STATE::parse_venue() { // Write the client_state.xml file // int CLIENT_STATE::write_state_file() { - unsigned int i, j; FILE* f = boinc_fopen(STATE_FILE_TEMP, "w"); int retval; @@ -195,6 +194,19 @@ int CLIENT_STATE::write_state_file() { msg_printf(0, MSG_ERROR, "Can't open temp state file: %s\n", STATE_FILE_TEMP); return ERR_FOPEN; } + retval = write_state(f); + fclose(f); + if (retval) return retval; + retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME); + scope_messages.printf("CLIENT_STATE::write_state_file(): Done writing state file\n"); + if (retval) return ERR_RENAME; + return 0; +} + +int CLIENT_STATE::write_state(FILE* f) { + unsigned int i, j; + int retval; + fprintf(f, "\n"); retval = host_info.write(f); if (retval) return retval; @@ -261,10 +273,6 @@ int CLIENT_STATE::write_state_file() { fprintf(f, "%s\n", host_venue); } fprintf(f, "\n"); - fclose(f); - retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME); - scope_messages.printf("CLIENT_STATE::write_state_file(): Done writing state file\n"); - if (retval) return ERR_RENAME; return 0; } diff --git a/client/gui_rpc_client.C b/client/gui_rpc_client.C index 21857f0d52..3ce28abcfd 100644 --- a/client/gui_rpc_client.C +++ b/client/gui_rpc_client.C @@ -29,116 +29,15 @@ RPC_CLIENT::~RPC_CLIENT() { fclose(fout); } -int RPC_CLIENT::get_projects(vector& projects) { +int RPC_CLIENT::get_state() { char buf[256]; int retval; - fprintf(fout, "\n"); + fprintf(fout, "\n"); fflush(fout); while (fgets(buf, 256, fin)) { - if (match_tag(buf, "")) continue; - else if (match_tag(buf, "")) return 0; - else if (match_tag(buf, "")) { - PROJECT project; - retval = project.parse_state(fin); - if (!retval) { - projects.push_back(project); - } - } else { - fprintf(stderr, "unrecognized: %s", buf); - } + printf(buf); + if (match_tag(buf, "")) break; } - return ERR_XML_PARSE; + return 0; } - -int PROJECT::parse_state(FILE* in) { - char buf[256]; - STRING256 string; - - strcpy(project_name, ""); - strcpy(user_name, ""); - strcpy(team_name, ""); - resource_share = 100; - exp_avg_cpu = 0; - exp_avg_mod_time = 0; - min_rpc_time = 0; - min_report_min_rpc_time = 0; - nrpc_failures = 0; - master_url_fetch_pending = false; - sched_rpc_pending = false; - scheduler_urls.clear(); - while (fgets(buf, 256, in)) { - if (match_tag(buf, "")) return 0; - else if (parse_str(buf, "", string.text, sizeof(string.text))) { - scheduler_urls.push_back(string); - continue; - } - else if (parse_str(buf, "", master_url, sizeof(master_url))) continue; - else if (parse_str(buf, "", project_name, sizeof(project_name))) continue; - else if (parse_str(buf, "", user_name, sizeof(user_name))) continue; - else if (parse_str(buf, "", team_name, sizeof(team_name))) continue; - else if (parse_double(buf, "", user_total_credit)) continue; - else if (parse_double(buf, "", user_expavg_credit)) continue; - else if (parse_int(buf, "", (int &)user_create_time)) continue; - else if (parse_int(buf, "", rpc_seqno)) continue; - else if (parse_int(buf, "", hostid)) continue; - else if (parse_double(buf, "", host_total_credit)) continue; - else if (parse_double(buf, "", host_expavg_credit)) continue; - else if (parse_int(buf, "", (int &)host_create_time)) continue; - else if (parse_double(buf, "", exp_avg_cpu)) continue; - else if (parse_int(buf, "", exp_avg_mod_time)) continue; - else if (match_tag(buf, "")) { - copy_element_contents( - in, - "", - code_sign_key, - sizeof(code_sign_key) - ); - } - else if (parse_int(buf, "", nrpc_failures)) continue; - else if (parse_int(buf, "", master_fetch_failures)) continue; - else if (parse_int(buf, "", (int&)min_rpc_time)) continue; - else if (match_tag(buf, "")) master_url_fetch_pending = true; - else if (match_tag(buf, "")) sched_rpc_pending = true; - else printf("PROJECT::parse_state(): unrecognized: %s\n", buf); - } - return ERR_XML_PARSE; -} - -PROJECT::PROJECT() { - init(); -} - -void PROJECT::init() { - strcpy(master_url, ""); - strcpy(authenticator, ""); - project_specific_prefs = ""; - resource_share = 100; - strcpy(project_name, ""); - strcpy(user_name, ""); - strcpy(team_name, ""); - user_total_credit = 0; - user_expavg_credit = 0; - user_create_time = 0; - rpc_seqno = 0; - hostid = 0; - host_total_credit = 0; - host_expavg_credit = 0; - host_create_time = 0; - exp_avg_cpu = 0; - exp_avg_mod_time = 0; - strcpy(code_sign_key, ""); - nrpc_failures = 0; - min_rpc_time = 0; - min_report_min_rpc_time = 0; - master_fetch_failures = 0; - resource_debt = 0; - debt_order = 0; - master_url_fetch_pending = false; - sched_rpc_pending = false; - tentative = false; -} - -PROJECT::~PROJECT() { -} - diff --git a/client/gui_rpc_client.h b/client/gui_rpc_client.h index ae4a18349b..f9ab027945 100644 --- a/client/gui_rpc_client.h +++ b/client/gui_rpc_client.h @@ -1,7 +1,5 @@ #include -#include "client_types.h" - class RPC_CLIENT { int sock; FILE* fin; @@ -9,6 +7,6 @@ class RPC_CLIENT { public: ~RPC_CLIENT(); int init(char*); - int get_projects(vector&); + int get_state(); }; diff --git a/client/gui_rpc_server.C b/client/gui_rpc_server.C index fa63e732be..cc6f1b6db4 100644 --- a/client/gui_rpc_server.C +++ b/client/gui_rpc_server.C @@ -34,19 +34,8 @@ int GUI_RPC_CONN::handle_rpc() { if (n <= 0) return -1; buf[n] = 0; printf("got %s\n", buf); - if (match_tag(buf, "\n"); - for (i=0; iwrite_state(fout); - } - fprintf(fout, "\n"); - } else if match_tag(buf, ")) { - fprintf(fout, "\n"); - for (i=0; iwrite_state(fout); - } + if (match_tag(buf, "\n"); } diff --git a/client/gui_test.C b/client/gui_test.C index 7f09299051..a1fd059914 100644 --- a/client/gui_test.C +++ b/client/gui_test.C @@ -4,13 +4,8 @@ main() { RPC_CLIENT rpc; - vectorprojects; unsigned int i; rpc.init("gui_rpc"); - rpc.get_projects(projects); - for (i=0; i