From 60c82d004509428097cafe4c3cca9a1ca7a4eeb5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 20 Apr 2004 02:47:51 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3273 --- checkin_notes | 23 +++++++++++++++++++++++ client/client_state.C | 8 ++++++++ client/client_types.C | 8 ++++++-- client/net_xfer.C | 20 ++++++++------------ client/net_xfer.h | 5 ++--- client/prefs.C | 2 ++ client/win/wingui.cpp | 2 +- client/win/wingui_proxydlg.cpp | 4 ++-- lib/filesys.C | 4 ++-- lib/filesys.h | 2 +- 10 files changed, 55 insertions(+), 23 deletions(-) diff --git a/checkin_notes b/checkin_notes index 6d0b05c1d9..4d0cd74364 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11674,3 +11674,26 @@ David April 18 2004 sched/ db_dump.C server_types.C + +David April 19 2004 + - Client: change the way network transfer speed is computed. + Instead of computing it every 3 seconds (which doesn't work + for short transfers) just computed it from start of transfer. + - when detach from a project, and global prefs are from that project, + delete the global prefs file and init() prefs in mem. + Otherwise you have prefs from unknown project. + - write element in only if writing to server + (avoid error parsing state file) + - some message end with multiple \n's. delete them all. + - change return type of boinc_file_exists() to bool + + client/ + client_state.C + client_types.C + net_xfer.C,h + prefs.C + win/ + wingui.cpp + wingui_proxydlg.cpp + lib/ + filesys.C,h diff --git a/client/client_state.C b/client/client_state.C index 2aafe4e24f..65cd95e73f 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -1129,6 +1129,14 @@ int CLIENT_STATE::detach_project(PROJECT* project) { } } + // if global prefs came from this project, delete file and reinit + // + p = lookup_project(global_prefs.source_project.c_str()); + if (p == project) { + boinc_delete_file(GLOBAL_PREFS_FILE_NAME); + global_prefs.init(); + } + // find project and remove it from the vector // for (project_iter = projects.begin(); project_iter != projects.end(); project_iter++) { diff --git a/client/client_types.C b/client/client_types.C index f96e8e10b9..9aeb932147 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -979,14 +979,18 @@ int RESULT::write(FILE* out, bool to_server) { " %s\n" " %f\n" " %d\n" - " %d\n" " %d\n", name, final_cpu_time, exit_status, - wup->version_num, state ); + if (to_server) { + fprintf(out, + " %d\n", + wup->version_num + ); + } n = stderr_out.length(); if (n) { fprintf(out, "\n"); diff --git a/client/net_xfer.C b/client/net_xfer.C index efc8e38142..1bc7005bb0 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -265,9 +265,7 @@ void NET_XFER::init(char* host, int p, int b) { safe_strcpy(hostname, host); port = p; blocksize = (b > MAX_BLOCKSIZE ? MAX_BLOCKSIZE : b); - xfer_speed = 0; - last_speed_update = dtime(); - recent_bytes_xferred = 0; + start_time = dtime(); file_read_buf_offset = 0; file_read_buf_len = 0; bytes_xferred = 0; @@ -589,17 +587,15 @@ int NET_XFER::do_xfer(int& nbytes_transferred) { } // Update the transfer speed for this NET_XFER +// called on every I/O // void NET_XFER::update_speed(int nbytes) { - double now, delta_t; - - recent_bytes_xferred += nbytes; - now = dtime(); - delta_t = now - last_speed_update; - if (delta_t < 3.0) return; - xfer_speed = recent_bytes_xferred/delta_t; - last_speed_update = now; - recent_bytes_xferred = 0; + double delta_t = dtime() - start_time; + if (delta_t > 0) { + xfer_speed = bytes_xferred / delta_t; + } else if (xfer_speed == 0) { + xfer_speed = 999999999; + } } void NET_XFER::got_error() { diff --git a/client/net_xfer.h b/client/net_xfer.h index 8c41c5351e..f372495ee0 100644 --- a/client/net_xfer.h +++ b/client/net_xfer.h @@ -56,9 +56,8 @@ public: int error; int port; int blocksize; - double xfer_speed; // computed every 3 seconds - double last_speed_update; // when xfer_speed was last computed - double recent_bytes_xferred; // bytes xferred since last_speed_update + double start_time; + double xfer_speed; double bytes_xferred; // bytes transferred in this session char file_read_buf[MAX_BLOCKSIZE]; int file_read_buf_offset, file_read_buf_len; diff --git a/client/prefs.C b/client/prefs.C index e3897b46c1..8243ff35ff 100644 --- a/client/prefs.C +++ b/client/prefs.C @@ -65,6 +65,8 @@ void GLOBAL_PREFS::init() { max_memory_mbytes = 128; proc_priority = 1; cpu_affinity = -1; + source_project = ""; + source_scheduler = ""; }; GLOBAL_PREFS::GLOBAL_PREFS() { diff --git a/client/win/wingui.cpp b/client/win/wingui.cpp index 01bef8c83e..319022aada 100755 --- a/client/win/wingui.cpp +++ b/client/win/wingui.cpp @@ -28,7 +28,7 @@ void show_message(PROJECT* p, char* msg, int priority) { char message[1024]; strcpy(message, msg); - if (message[strlen(message)-1] == '\n') { + while (strlen(message)&&message[strlen(message)-1] == '\n') { message[strlen(message)-1] = 0; } if (p) { diff --git a/client/win/wingui_proxydlg.cpp b/client/win/wingui_proxydlg.cpp index fec0f1615b..1f295de17e 100644 --- a/client/win/wingui_proxydlg.cpp +++ b/client/win/wingui_proxydlg.cpp @@ -167,11 +167,11 @@ void CProxyServerDlg::OnOK() { UpdateData(TRUE); - gstate.pi.use_http_proxy = m_UseHTTPProxyServerCtrl.GetCheck(); + gstate.pi.use_http_proxy = (m_UseHTTPProxyServerCtrl.GetCheck() != 0); safe_strncpy(gstate.pi.http_server_name, m_strHTTPProxyServerAddress.GetBuffer(), sizeof(gstate.pi.http_server_name)); gstate.pi.http_server_port = m_uiHTTPProxyServerPort; - gstate.pi.use_socks_proxy = m_UseSOCKSProxyServerCtrl.GetCheck(); + gstate.pi.use_socks_proxy = (m_UseSOCKSProxyServerCtrl.GetCheck() != 0); safe_strncpy(gstate.pi.socks_server_name, m_strSOCKSProxyServerAddress.GetBuffer(), sizeof(gstate.pi.socks_server_name)); gstate.pi.socks_server_port = m_uiSOCKSProxyServerPort; safe_strncpy(gstate.pi.socks5_user_name, m_strSOCKSProxyServerUsername.GetBuffer(), sizeof(gstate.pi.socks5_user_name)); diff --git a/lib/filesys.C b/lib/filesys.C index 86e7ffe7d2..065e70a1a0 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -354,11 +354,11 @@ FILE* boinc_fopen(const char* path, const char* mode) { } -int boinc_file_exists(const char* path) { +bool boinc_file_exists(const char* path) { struct stat buf; if (stat(path, &buf)) { - return false; + return false; // stat() returns zero on success } return true; } diff --git a/lib/filesys.h b/lib/filesys.h index bc1827f50e..b16f95b0e5 100755 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -65,7 +65,7 @@ extern int file_size(const char*, double&); extern int clean_out_dir(const char*); extern int dir_size(const char* dirpath, double&); extern FILE* boinc_fopen(const char* path, const char* mode); -extern int boinc_file_exists(const char* path); +extern bool boinc_file_exists(const char* path); extern int boinc_copy(const char* orig, const char* newf); extern int boinc_rename(const char* old, const char* newf); extern int boinc_mkdir(const char*);