From 921b5c50df79b9bb13d43e3c8f05fc362d1a20e7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 13 Oct 2011 19:05:18 +0000 Subject: [PATCH] - client: create and destroy PERS_FILE_XFERs even if network suspended. This will show pending uploads in the Transfers tab. - file_upload_handler: fix message to client when can't acquire lock - client: parse in state file correctly svn path=/trunk/boinc/; revision=24391 --- checkin_notes | 14 ++++++++++++++ client/client_state.cpp | 2 +- client/cs_files.cpp | 5 +++-- client/cs_statefile.cpp | 3 ++- client/sim.cpp | 1 - sched/file_upload_handler.cpp | 6 +++++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/checkin_notes b/checkin_notes index 803c23fa27..761b7ec95a 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7182,3 +7182,17 @@ David 13 Oct 2011 client/ cs_prefs.cpp + +David 13 Oct 2011 + - client: create and destroy PERS_FILE_XFERs even if network suspended. + This will show pending uploads in the Transfers tab. + - file_upload_handler: fix message to client when can't acquire lock + - client: parse in state file correctly + + client/ + client_stte.cpp + sim.cpp + cs_statefile.cpp + cs_files.cpp + sched/ + file_upload_handler.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index 9f83b172a0..6b60a03ff8 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -857,6 +857,7 @@ bool CLIENT_STATE::poll_slow_events() { POLL_ACTION(gui_http , gui_http.poll ); POLL_ACTION(gui_rpc_http , gui_rpcs.poll ); POLL_ACTION(trickle_up_ops, trickle_up_poll); + POLL_ACTION(handle_pers_file_xfers , handle_pers_file_xfers ); if (!network_suspended && suspend_reason != SUSPEND_REASON_BENCHMARKS) { // don't initiate network activity if we're doing CPU benchmarks net_status.poll(); @@ -864,7 +865,6 @@ bool CLIENT_STATE::poll_slow_events() { POLL_ACTION(acct_mgr , acct_mgr_info.poll ); POLL_ACTION(file_xfers , file_xfers->poll ); POLL_ACTION(pers_file_xfers , pers_file_xfers->poll ); - POLL_ACTION(handle_pers_file_xfers , handle_pers_file_xfers ); if (!config.no_info_fetch) { POLL_ACTION(rss_feed_op , rss_feed_op.poll ); } diff --git a/client/cs_files.cpp b/client/cs_files.cpp index 5ca868ee8d..7deddcdc16 100644 --- a/client/cs_files.cpp +++ b/client/cs_files.cpp @@ -233,8 +233,9 @@ int FILE_INFO::verify_file(bool strict, bool show_errors) { } #ifndef SIM -// scan all FILE_INFOs and PERS_FILE_XFERs. -// start and finish downloads and uploads as needed. +// scan FILE_INFOs and create PERS_FILE_XFERs as needed. +// NOTE: this doesn't start the file transfers +// scan PERS_FILE_XFERs and delete finished ones. // bool CLIENT_STATE::handle_pers_file_xfers() { unsigned int i; diff --git a/client/cs_statefile.cpp b/client/cs_statefile.cpp index a0d8646f73..8b47828a07 100644 --- a/client/cs_statefile.cpp +++ b/client/cs_statefile.cpp @@ -114,6 +114,7 @@ int CLIENT_STATE::parse_state_file_aux(const char* fname) { int retval=0; int failnum; bool btemp; + string stemp; FILE* f = fopen(fname, "r"); if (!f) return ERR_FOPEN; @@ -438,7 +439,7 @@ int CLIENT_STATE::parse_state_file_aux(const char* fname) { if (xp.parse_string("platform_name", statefile_platform_name)) { continue; } - if (xp.match_tag("alt_platform")) { + if (xp.parse_string("alt_platform", stemp)) { continue; } if (xp.parse_int("user_run_request", retval)) { diff --git a/client/sim.cpp b/client/sim.cpp index d68f7de6c3..9e4a25c75b 100644 --- a/client/sim.cpp +++ b/client/sim.cpp @@ -1281,7 +1281,6 @@ void do_client_simulation() { sprintf(buf, "%s%s", config_prefix, CONFIG_FILE); config.defaults(); read_config_file(true, buf); - config.show(); gstate.add_platform("client simulator"); sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME); diff --git a/sched/file_upload_handler.cpp b/sched/file_upload_handler.cpp index 9eee6d7686..87a9e8bda7 100644 --- a/sched/file_upload_handler.cpp +++ b/sched/file_upload_handler.cpp @@ -131,12 +131,16 @@ int copy_socket_to_file(FILE* in, char* path, double offset, double nbytes) { // This will prevent OTHER instances of file_upload_handler // from being able to write to the file. // - if ((pid=mylockf(fd))) { + pid = mylockf(fd); + if (pid>0) { close(fd); return return_error(ERR_TRANSIENT, "can't lock file %s: %s locked by PID=%d\n", path, strerror(errno), pid ); + } else if (pid < 0) { + close(fd); + return return_error(ERR_TRANSIENT, "can't lock file %s\n", path); } // check that file length corresponds to offset