From aa6b06a2a94ceebb9c50ef900919a23e3cf14a23 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 28 Jan 2005 19:01:08 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=5236 --- checkin_notes | 13 +++++++++++++ client/client_msgs.C | 6 +++++- client/client_msgs.h | 2 +- client/client_state.C | 2 +- client/gui_rpc_server.C | 8 ++------ client/time_stats.C | 12 +++++++----- client/time_stats.h | 8 +++++--- db/boinc_db.h | 6 +++--- 8 files changed, 37 insertions(+), 20 deletions(-) diff --git a/checkin_notes b/checkin_notes index e787a288de..ac26540e00 100755 --- a/checkin_notes +++ b/checkin_notes @@ -23367,3 +23367,16 @@ David 28 Jan 2005 sched/ server_types.C + +David 28 Jan 2005 + - core client: in MESSAGE_DESC + (used to save messages, so they can be sent to core client) + store project name, instead of pointer to project. + By the time we send msg to GUI, the project object might be deleted! + - improve time_stats + + client/ + client_msgs.C,h + client_state.C + gui_rpc_server.C + time_stats.C,h diff --git a/client/client_msgs.C b/client/client_msgs.C index 4ae423e0c7..e25dedcfa3 100644 --- a/client/client_msgs.C +++ b/client/client_msgs.C @@ -28,6 +28,7 @@ using std::deque; #include "log_flags.h" +#include "client_types.h" #include "client_msgs.h" #define MAX_SAVED_MESSAGES 1000 @@ -99,7 +100,10 @@ void msg_printf(PROJECT *p, int priority, char *fmt, ...) { void record_message(PROJECT* p, int priority, int now, char* message) { MESSAGE_DESC* mdp = new MESSAGE_DESC; static int seqno = 1; - mdp->project = p; + strcpy(mdp->project_name, ""); + if (p) { + strcpy(mdp->project_name, p->get_project_name()); + } mdp->priority = priority; mdp->timestamp = now; mdp->seqno = seqno++; diff --git a/client/client_msgs.h b/client/client_msgs.h index 9dd78bf64d..10b3edd082 100644 --- a/client/client_msgs.h +++ b/client/client_msgs.h @@ -52,7 +52,7 @@ class PROJECT; // the following stores a message in memory, where it can be retrieved via RPC // struct MESSAGE_DESC { - PROJECT* project; + char project_name[256]; int priority; int timestamp; int seqno; diff --git a/client/client_state.C b/client/client_state.C index b8f8c0c1e9..f9e8a5e927 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -471,7 +471,7 @@ bool CLIENT_STATE::do_something(double now) { if (actions > 0) { return true; } else { - time_stats.update(true, !activities_suspended); + time_stats.update(now, true, !activities_suspended); return false; } } diff --git a/client/gui_rpc_server.C b/client/gui_rpc_server.C index 4165e55266..e184cd2aee 100644 --- a/client/gui_rpc_server.C +++ b/client/gui_rpc_server.C @@ -303,21 +303,17 @@ void handle_get_messages(char* buf, MIOFILE& fout) { mdp = message_descs[i]; fout.printf( "\n" + " %s\n" " %d\n" " %d\n" " \n%s\n\n" " \n", + mdp->project_name, mdp->priority, mdp->seqno, mdp->message.c_str(), mdp->timestamp ); - if (mdp->project) { - fout.printf( - " %s\n", - mdp->project->get_project_name() - ); - } fout.printf("\n"); } fout.printf("\n"); diff --git a/client/time_stats.C b/client/time_stats.C index 380191306f..2d46067694 100644 --- a/client/time_stats.C +++ b/client/time_stats.C @@ -49,10 +49,12 @@ TIME_STATS::TIME_STATS() { } // Update time statistics based on current activities +// NOTE: we don't set the state-file dirty flag here, +// so these get written to disk only when other activities +// cause this to happen. Maybe should change this. // -void TIME_STATS::update(bool is_connected, bool is_active) { - int now = time(0), dt; - double w1, w2; +void TIME_STATS::update(double now, bool is_connected, bool is_active) { + double dt, w1, w2; if (last_update == 0) { // this is the first time this client has executed. @@ -60,12 +62,12 @@ void TIME_STATS::update(bool is_connected, bool is_active) { on_frac = 1; connected_frac = is_connected?1:0; - active_frac = true; + active_frac = is_active?1:0; first = false; last_update = now; } else { dt = now - last_update; - if (dt <= 0) return; + if (dt <= 10) return; w1 = 1 - exp(-dt/ALPHA); w2 = 1 - w1; if (first) { diff --git a/client/time_stats.h b/client/time_stats.h index d7bba09b0c..b9be28f504 100644 --- a/client/time_stats.h +++ b/client/time_stats.h @@ -27,12 +27,14 @@ public: double on_frac; // the fraction of total time this host runs the core client double connected_frac; - // the fraction of total time the host is connected to the Internet + // of the time this host runs the core client, + // the fraction it is connected to the Internet double active_frac; - // the fraction of total time the core client is able to work + // of the time this host runs the core client, + // the fraction it is enabled to work // (due to preferences, manual suspend/resume, etc.) - void update(bool is_connected, bool is_active); + void update(double now, bool is_connected, bool is_active); TIME_STATS(); int write(MIOFILE&, bool to_server); diff --git a/db/boinc_db.h b/db/boinc_db.h index 64f305f82e..013010e7f3 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -217,9 +217,9 @@ struct HOST { char last_ip_addr[256]; // internal IP address as of last RPC int nsame_ip_addr; // # of RPCs with same IP address - double on_frac; // Fraction of time (0-1) that BOINC is running - double connected_frac; // Fraction of time that host is connected to net - double active_frac; // Fraction of time that host is enabled to work + double on_frac; // see client/time_stats.h + double connected_frac; + double active_frac; int p_ncpus; // Number of CPUs on host char p_vendor[256]; // Vendor name of CPU