From c02e5dfa4a11ee52acb01b9475e25563412f54fe Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 25 Oct 2004 20:16:30 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4423 --- api/boinc_api.C | 2 +- api/boinc_api.h | 8 +------ api/graphics_api.C | 7 +++--- checkin_notes | 32 ++++++++++++++++++++++++++ client/client_state.C | 4 ++-- client/client_types.h | 12 +++++----- client/cs_prefs.C | 1 - client/cs_scheduler.C | 20 ++++++++--------- client/net_xfer.h | 2 +- client/pers_file_xfer.C | 46 ++++++++++++++++---------------------- client/pers_file_xfer.h | 4 ++-- client/scheduler_op.C | 6 ++--- client/scheduler_op.h | 2 +- client/ss_logic.C | 2 +- client/ss_logic.h | 6 ++--- lib/parse.C | 4 ++-- lib/util.C | 12 +++++----- lib/util.h | 6 ++--- win_build/boinc_gui.vcproj | 11 +++++---- 19 files changed, 104 insertions(+), 83 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index 9b8922e978..af34a04c12 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -98,7 +98,7 @@ static bool heartbeat_active; // if false, suppress heartb //HANDLE hSuspendRequest; //HANDLE hResumeRequest; static HANDLE hSharedMem; -static HANDLE worker_thread_handle; +HANDLE worker_thread_handle; static MMRESULT timer_id; #endif diff --git a/api/boinc_api.h b/api/boinc_api.h index 17fda82a38..cc1d2390fc 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -87,13 +87,7 @@ extern APP_INIT_DATA aid; /////////// IMPLEMENTATION STUFF BEGINS HERE extern APP_CLIENT_SHM *app_client_shm; - -#if 0 -#ifdef HAVE_SIGNAL_H -extern void boinc_catch_signal(int signal); -extern void boinc_quit(int sig); -#endif -#endif +extern HANDLE worker_thread_handle; /////////// IMPLEMENTATION STUFF ENDS HERE diff --git a/api/graphics_api.C b/api/graphics_api.C index e927d82af3..a0a44ee10e 100755 --- a/api/graphics_api.C +++ b/api/graphics_api.C @@ -25,7 +25,6 @@ #ifdef _WIN32 #include "boinc_win.h" extern void win_graphics_event_loop(); -HANDLE worker_threadh=NULL; #endif #ifdef __APPLE_CC__ @@ -96,7 +95,7 @@ int boinc_init_graphics(void (*_worker_main)()) { // Create the graphics thread, passing it the graphics info // TODO: is it better to use _beginthreadex here? // - worker_threadh = CreateThread( + worker_thread_handle = CreateThread( NULL, 0, foobar, 0, CREATE_SUSPENDED, &threadId ); @@ -107,11 +106,11 @@ int boinc_init_graphics(void (*_worker_main)()) { // lower worker thread priority // - SetThreadPriority(worker_threadh, THREAD_PRIORITY_LOWEST); + SetThreadPriority(worker_thread_handle, THREAD_PRIORITY_LOWEST); // Start the worker thread // - ResumeThread(worker_threadh); + ResumeThread(worker_thread_handle); graphics_inited = true; win_graphics_event_loop(); diff --git a/checkin_notes b/checkin_notes index 0f6da0f54f..734b22142d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -18798,3 +18798,35 @@ David 22 Oct 2004 client/ client_state.C cs_apps.C + +David 25 Oct 2004 + - Use double instead of time_t to represent time; + use dtime() instead of time(0) to get time + - better error message on upload init failure + - add lib/result_state.h to VC project + + client/ + client_state.C + client_types.h + cs_prefs.C + cs_scheduler.C + net_xfer.h + pers_file_xfer.C,h + schedule_op.C,h + ss_logic.C,h + lib/ + util.C,h + win_build/ + boinc_gui.vcproj + +David 25 Oct 2004 + - fixed bug that caused app's reported CPU time to always stay at zero + This is a by-product of recent graphics changes: + boinc_init() was getting the current thread handle and assuming + it's the worker thread, which is not the case now. + Fix: use a single variable for worker thread handle; + if boinc_graphics_init() is called, it changes it + + api/ + boinc_api.C,h + graphics_api.C diff --git a/client/client_state.C b/client/client_state.C index a367014f59..6d0fbea804 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -663,7 +663,7 @@ int CLIENT_STATE::link_result(PROJECT* p, RESULT* rp) { // void CLIENT_STATE::print_summary() { unsigned int i; - int t; + double t, now=dtime(); if (!log_flags.state_debug) return; SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE); @@ -673,7 +673,7 @@ void CLIENT_STATE::print_summary() { for (i=0; imin_rpc_time; if (t) { - scope_messages.printf(" %s min RPC %d seconds from now\n", projects[i]->master_url, (int)(t-time(0))); + scope_messages.printf(" %s min RPC %f.0 seconds from now\n", projects[i]->master_url, t-now); } else { scope_messages.printf(" %s\n", projects[i]->master_url); } diff --git a/client/client_types.h b/client/client_types.h index 67415a8f87..fa3c56bf7f 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -89,8 +89,8 @@ public: // this is the signature #if 0 int priority; - time_t time_last_used; // time of last use of FILE_INFO, update during parsing, writing, or application usage - time_t exp_date; + double time_last_used; // time of last use of FILE_INFO, update during parsing, writing, or application usage + double exp_date; #endif std::string error_msg; // if permanent error occurs during file xfer, // it's recorded here @@ -186,9 +186,9 @@ public: int nrpc_failures; // # of consecutive times we've failed to // contact all scheduling servers int master_fetch_failures; - time_t min_rpc_time; // earliest time to contact any server + double min_rpc_time; // earliest time to contact any server // of this project (or zero) - time_t min_report_min_rpc_time; // when to next report on min_rpc_time + double min_report_min_rpc_time; // when to next report on min_rpc_time // (or zero) bool master_url_fetch_pending; // need to fetch and parse the master URL @@ -238,9 +238,9 @@ public: #endif // set min_rpc_time and have_reported_min_rpc_time - void set_min_rpc_time(time_t future_time); + void set_min_rpc_time(double future_time); // returns true if min_rpc_time > now; may print a message - bool waiting_until_min_rpc_time(time_t now); + bool waiting_until_min_rpc_time(double now); }; struct APP { diff --git a/client/cs_prefs.C b/client/cs_prefs.C index 4e1950019c..c48b838958 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -114,7 +114,6 @@ int CLIENT_STATE::allowed_project_disk_usage(double& size) { // inline bool now_between_two_hours(int start_hour, int end_hour) { if (start_hour == end_hour) { - // always work return true; } diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 86dc167dce..c5fb5d3f5e 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -69,17 +69,17 @@ const int SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN = 60*60; static int proj_min_results(PROJECT* p, int ncpus) { return (int)(ceil(ncpus*p->resource_share/trs)); } -void PROJECT::set_min_rpc_time(time_t future_time) { +void PROJECT::set_min_rpc_time(double future_time) { if (future_time > min_rpc_time) { min_rpc_time = future_time; } - min_report_min_rpc_time = 0; // report immediately + min_report_min_rpc_time = 0; } // Return true iff we should not contact the project yet. // Print a message to the user if we haven't recently // -bool PROJECT::waiting_until_min_rpc_time(time_t now) { +bool PROJECT::waiting_until_min_rpc_time(double now) { if (min_rpc_time > now ) { if (now >= min_report_min_rpc_time) { min_report_min_rpc_time = now + SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN; @@ -99,7 +99,7 @@ bool PROJECT::waiting_until_min_rpc_time(time_t now) { PROJECT* CLIENT_STATE::next_project_master_pending() { unsigned int i; PROJECT* p; - time_t now = time(0); + double now = dtime(); for (i=0; iwaiting_until_min_rpc_time(now)) continue; @@ -133,7 +133,7 @@ PROJECT* CLIENT_STATE::next_project_sched_rpc_pending() { // PROJECT* CLIENT_STATE::next_project_need_work(PROJECT *old) { PROJECT *p; - time_t now = time(0); + double now = dtime(); unsigned int i; bool found_old = (old == 0); for (i=0; imin_rpc_time < now) return true; @@ -385,7 +385,7 @@ int CLIENT_STATE::compute_work_requests() { int urgency = DONT_NEED_WORK; unsigned int i; double work_min_period = global_prefs.work_buf_min_days * SECONDS_PER_DAY; - time_t now = time(0); + double now = dtime(); trs = total_resource_share(); @@ -520,7 +520,7 @@ int CLIENT_STATE::handle_scheduler_reply( if (retval) return retval; if (sr.request_delay) { - time_t x = time(0) + sr.request_delay; + double x = dtime() + sr.request_delay; if (x > project->min_rpc_time) project->min_rpc_time = x; } diff --git a/client/net_xfer.h b/client/net_xfer.h index 8ab6107e18..561022182b 100644 --- a/client/net_xfer.h +++ b/client/net_xfer.h @@ -92,7 +92,7 @@ public: // total bytes transferred bool up_active, down_active; // has there been transfer activity since last call to check_active()? - time_t last_time; + double last_time; int insert(NET_XFER*); int remove(NET_XFER*); bool poll(double); diff --git a/client/pers_file_xfer.C b/client/pers_file_xfer.C index 1627f2a1b5..a0a52f4a7e 100644 --- a/client/pers_file_xfer.C +++ b/client/pers_file_xfer.C @@ -135,22 +135,17 @@ int PERS_FILE_XFER::start_xfer() { retval = file_xfer->init_download(*fip); } fxp = file_xfer; + if (!retval) retval = gstate.file_xfers->insert(file_xfer); if (retval) { msg_printf( - fip->project, MSG_ERROR, "Couldn't start %s for %s: error %d", - (is_upload ? "upload" : "download"), fip->get_current_url(is_upload), retval + fip->project, MSG_ERROR, "Couldn't start %s of %s", + (is_upload ? "upload" : "download"), fip->name ); - handle_xfer_failure(); - delete fxp; - fxp = NULL; - return retval; - } - retval = gstate.file_xfers->insert(file_xfer); - if (retval) { msg_printf( - fip->project, MSG_ERROR, "Couldn't start %s for %s: error %d", - (is_upload ? "upload" : "download"), fip->get_current_url(is_upload), retval + fip->project, MSG_ERROR, "URL %s: error %d", + fip->get_current_url(is_upload), retval ); + fxp->file_xfer_retval = retval; handle_xfer_failure(); delete fxp; @@ -322,7 +317,7 @@ void PERS_FILE_XFER::check_giveup(char* why) { // Handle a transfer failure // void PERS_FILE_XFER::handle_xfer_failure() { - time_t now = time(0); + double now = dtime(); // If it was a bad range request, delete the file and start over // @@ -355,15 +350,10 @@ void PERS_FILE_XFER::handle_xfer_failure() { // backoff and try again later // void PERS_FILE_XFER::retry_or_backoff() { - // struct tm *newtime; - time_t now; - int backoff = 0; + double backoff = 0; SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_FILE_XFER); - now = time(0); - // newtime = localtime(&now); - // Cycle to the next URL to try // If we reach the URL that we started at, then we have tried all // servers without success @@ -380,12 +370,14 @@ void PERS_FILE_XFER::retry_or_backoff() { "pers_file_xfer", nretry, gstate.pers_retry_delay_min, gstate.pers_retry_delay_max ); - next_request_time = now + backoff; + next_request_time = dtime() + backoff; + msg_printf(fip->project, MSG_INFO, + "Backing off %s on %s of file %s", + timediff_format(backoff).c_str(), + is_upload?"upload":"download", + fip->name + ); } - msg_printf(fip->project, MSG_INFO, - "Backing off %s on transfer of file %s", - timediff_format(backoff).c_str(), fip->name - ); } void PERS_FILE_XFER::abort() { @@ -407,8 +399,8 @@ int PERS_FILE_XFER::parse(MIOFILE& fin) { while (fin.fgets(buf, 256)) { if (match_tag(buf, "")) return 0; else if (parse_int(buf, "", nretry)) continue; - else if (parse_int(buf, "", first_request_time)) continue; - else if (parse_int(buf, "", next_request_time)) continue; + else if (parse_double(buf, "", first_request_time)) continue; + else if (parse_double(buf, "", next_request_time)) continue; else if (parse_double(buf, "", time_so_far)) continue; else { msg_printf(fip->project, MSG_ERROR, "PERS_FILE_XFER::parse(): unrecognized: %s", buf); @@ -423,8 +415,8 @@ int PERS_FILE_XFER::write(MIOFILE& fout) { fout.printf( " \n" " %d\n" - " %d\n" - " %d\n" + " %f\n" + " %f\n" " %f\n" " \n", nretry, first_request_time, next_request_time, time_so_far diff --git a/client/pers_file_xfer.h b/client/pers_file_xfer.h index 3c45e992ae..615c3e71e2 100644 --- a/client/pers_file_xfer.h +++ b/client/pers_file_xfer.h @@ -43,11 +43,11 @@ class PERS_FILE_XFER { int nretry; // # of retries so far - int first_request_time; // UNIX time of first file request + double first_request_time; // time of first transfer request bool is_upload; public: - int next_request_time; // UNIX time to next retry the file request + double next_request_time; // UNIX time to next retry the file request double time_so_far; // Total time there's been an active FILE_XFER for this PFX // Currently not used for anything; not meaningful for throughput diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 70d8f8894a..7aac9af8b8 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -152,7 +152,7 @@ done: // based on exponential backoff // int SCHEDULER_OP::set_min_rpc_time(PROJECT* p) { - int exp_backoff; + double exp_backoff; int n = p->nrpc_failures; if (n > gstate.retry_cap) n = gstate.retry_cap; @@ -173,7 +173,7 @@ int SCHEDULER_OP::set_min_rpc_time(PROJECT* p) { gstate.retry_base_period ); } - p->set_min_rpc_time(time(0) + exp_backoff); + p->set_min_rpc_time(dtime() + exp_backoff); // note: we don't need to print a message now, it will be printed the // next time p->waiting_until_min_rpc_time() is called. return 0; @@ -612,7 +612,7 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) { else if (parse_double(buf, "", project->host_expavg_credit)) continue; else if (parse_str(buf, "", host_venue, sizeof(host_venue))) continue; else if (parse_int(buf, "", (int&)project->host_create_time)) continue; - else if (parse_int(buf, "", request_delay)) continue; + else if (parse_double(buf, "", request_delay)) continue; else if (match_tag(buf, "")) { retval = dup_element_contents( in, diff --git a/client/scheduler_op.h b/client/scheduler_op.h index 639d910458..2e71f7040e 100644 --- a/client/scheduler_op.h +++ b/client/scheduler_op.h @@ -86,7 +86,7 @@ struct SCHEDULER_OP { struct SCHEDULER_REPLY { int hostid; - int request_delay; + double request_delay; char message[1024]; char message_priority[256]; char* global_prefs_xml; diff --git a/client/ss_logic.C b/client/ss_logic.C index 1614b404e0..3f70f3bd3a 100644 --- a/client/ss_logic.C +++ b/client/ss_logic.C @@ -39,7 +39,7 @@ SS_LOGIC::SS_LOGIC() { // this is called when the core client receives a message // from the screensaver module. // -void SS_LOGIC::start_ss(time_t new_blank_time) { +void SS_LOGIC::start_ss(double new_blank_time) { ACTIVE_TASK* atp; if (do_ss) return; diff --git a/client/ss_logic.h b/client/ss_logic.h index 559b2dd372..0d62b846d8 100644 --- a/client/ss_logic.h +++ b/client/ss_logic.h @@ -43,14 +43,14 @@ #endif class SS_LOGIC { - time_t blank_time; // 0 or time to blank screen - time_t ack_deadline; // when to give up on graphics app + double blank_time; // 0 or time to blank screen + double ack_deadline; // when to give up on graphics app public: SS_LOGIC(); char ss_msg[256]; // message to display on BOINC screensaver - void start_ss(time_t blank_time); + void start_ss(double blank_time); void stop_ss(); void poll(); void reset(); diff --git a/lib/parse.C b/lib/parse.C index e33630ea45..bf29fcb288 100644 --- a/lib/parse.C +++ b/lib/parse.C @@ -169,7 +169,7 @@ int copy_element_contents(FILE* in, const char* end_tag, char* p, int len) { if (strstr(buf, end_tag)) { return 0; } - n = strlen(buf); + n = (int)strlen(buf); if (n >= len-1) return ERR_XML_PARSE; strcat(p, buf); len -= n; @@ -244,7 +244,7 @@ bool str_replace(char* str, char* substr, char* replacement) { p = strstr(str, substr); if (!p) return false; - int n = strlen(substr); + int n = (int)strlen(substr); strcpy(temp, p+n); strcpy(p, replacement); strcat(p, temp); diff --git a/lib/util.C b/lib/util.C index 5dd24a28a1..c19946babb 100755 --- a/lib/util.C +++ b/lib/util.C @@ -409,7 +409,7 @@ void escape_url_readable(char *in, char* out) { // void canonicalize_master_url(char* url) { char buf[1024]; - int n; + size_t n; char *p = strstr(url, "//"); if (p) { @@ -441,8 +441,9 @@ void safe_strncpy(char* dst, const char* src, int len) { dst[len-1]=0; } -char* time_to_string(time_t x) { +char* time_to_string(double t) { static char buf[100]; + time_t x = (time_t)t; struct tm* tm = localtime(&x); strftime(buf, sizeof(buf)-1, "%Y-%m-%d %H:%M:%S", tm); return buf; @@ -455,7 +456,7 @@ static int count_debug_fake_exponential_backoff = 0; static const int max_debug_fake_exponential_backoff = 1000; // safety limit // return a random integer in the range [MIN,min(e^n,MAX)) -int calculate_exponential_backoff( +double calculate_exponential_backoff( const char* debug_descr, int n, double MIN, double MAX, double factor /* = 1.0 */ ) { @@ -488,11 +489,12 @@ int calculate_exponential_backoff( return 0; } - return (int) rand_range(MIN, rmax); + return rand_range(MIN, rmax); } -string timediff_format(long tdiff) { +string timediff_format(double diff) { char buf[256]; + int tdiff = (int)diff; int sex = tdiff % 60; tdiff /= 60; diff --git a/lib/util.h b/lib/util.h index 39a4df14d9..90f3b76acd 100755 --- a/lib/util.h +++ b/lib/util.h @@ -52,8 +52,8 @@ extern void canonicalize_master_url(char *url); extern void safe_strncpy(char*, const char*, int); #define safe_strcpy(x, y) safe_strncpy(x, y, sizeof(x)) #define safe_strcat(x, y) if (strlen(x)+strlen(y) + + @@ -1348,10 +1351,10 @@ Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> + RelativePath="..\client\win\boinc.bmp"> + RelativePath="..\client\win\res\boinc.bmp"> @@ -1371,10 +1374,10 @@ + RelativePath="..\client\win\res\boincsm.bmp"> + RelativePath="..\client\win\boincsm.bmp">