diff --git a/checkin_notes b/checkin_notes index 49e5a7a153..b01e0e7357 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1315,3 +1315,13 @@ Rom 3 Feb 2012 async_file.cpp win_build/ boinc_cli.vcproj + +David 3 Feb 2012 + - client: debug async file copy. Seems to be working. + + client/ + app.cpp + app_start.cpp + async_file.cpp + lib/ + common_defs.h diff --git a/client/app.cpp b/client/app.cpp index 8a721073fc..de4cc52d38 100644 --- a/client/app.cpp +++ b/client/app.cpp @@ -985,6 +985,7 @@ static const char* task_state_name(int val) { case PROCESS_ABORTED: return "ABORTED"; case PROCESS_COULDNT_START: return "COULDNT_START"; case PROCESS_QUIT_PENDING: return "QUIT_PENDING"; + case PROCESS_COPY_PENDING: return "COPY_PENDING"; } return "Unknown"; } diff --git a/client/app_start.cpp b/client/app_start.cpp index 57043fd482..2857f19122 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -570,7 +570,10 @@ int ACTIVE_TASK::start(bool first_time) { // if (first_time || wup->project->anonymous_platform) { retval = setup_file(fip, fref, file_path, true, false); - if (retval) { + if (retval == ERR_IN_PROGRESS) { + set_task_state(PROCESS_COPY_PENDING, "start"); + return 0; + } else if (retval) { strcpy(buf, "Can't link app version file"); goto error; } @@ -591,6 +594,7 @@ int ACTIVE_TASK::start(bool first_time) { get_pathname(fref.file_info, file_path, sizeof(file_path)); retval = setup_file(fip, fref, file_path, true, true); if (retval == ERR_IN_PROGRESS) { + set_task_state(PROCESS_COPY_PENDING, "start"); return 0; } else if (retval) { strcpy(buf, "Can't link input file"); @@ -1110,12 +1114,13 @@ int ACTIVE_TASK::resume_or_start(bool first_time) { sprintf(buf, " (%s)", app_version->plan_class); } msg_printf(result->project, MSG_INFO, - "%s task %s using %s version %d%s", + "%s task %s using %s version %d%s in slot %d", str, result->name, app_version->app->name, app_version->version_num, - buf + buf, + slot ); } return 0; diff --git a/client/async_file.cpp b/client/async_file.cpp index 34097eedc7..5dc7b3484e 100644 --- a/client/async_file.cpp +++ b/client/async_file.cpp @@ -35,7 +35,8 @@ vector async_verifies; vector async_copies; int ASYNC_COPY::init( - ACTIVE_TASK* _atp, const char* from_path, const char* _to_path) { + ACTIVE_TASK* _atp, const char* from_path, const char* _to_path +) { atp = _atp; strcpy(to_path, _to_path); in = fopen(from_path, "rb"); @@ -75,6 +76,9 @@ int ASYNC_COPY::copy_chunk() { if (n <= 0) { // copy done. rename temp file // + fclose(in); + fclose(out); + in = out = NULL; retval = boinc_rename(temp_path, to_path); if (retval) { error(retval); @@ -88,10 +92,10 @@ int ASYNC_COPY::copy_chunk() { error(retval); } } - remove_async_copy(this); return 1; // tell caller we're done } else { int m = fwrite(buf, 1, n, out); + m = 0; if (m != n) { error(ERR_FWRITE); return 1; @@ -103,11 +107,11 @@ int ASYNC_COPY::copy_chunk() { // handle the failure of a copy; error out the result // void ASYNC_COPY::error(int retval) { + atp->set_task_state(PROCESS_COULDNT_START, "ASYNC_COPY::error"); gstate.report_result_error( *(atp->result), "Couldn't copy file: %s", boincerror(retval) ); gstate.request_schedule_cpus("start failed"); - remove_async_copy(this); } void remove_async_copy(ASYNC_COPY* acp) { @@ -117,6 +121,7 @@ void remove_async_copy(ASYNC_COPY* acp) { async_copies.erase(i); break; } + i++; } delete acp; } diff --git a/lib/common_defs.h b/lib/common_defs.h index ec728ed96d..2b0238b3a5 100644 --- a/lib/common_defs.h +++ b/lib/common_defs.h @@ -139,6 +139,8 @@ enum SUSPEND_REASON { // process exceeded limits; send "abort" message, waiting to exit #define PROCESS_QUIT_PENDING 8 // we've sent it a "quit" message, waiting to exit +#define PROCESS_COPY_PENDING 10 + // waiting for async file copies to finish // states in which the process has exited #define PROCESS_EXITED 2