From cea4b691d98d7d0c2e02980256b7fb10d8069c52 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 20 Feb 2003 00:06:07 +0000 Subject: [PATCH] use iterator svn path=/trunk/boinc/; revision=948 --- client/app.C | 42 ++++++++++++++++++++++++++++-------------- client/cs_files.C | 24 ++++++++++++------------ todo | 19 ++----------------- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/client/app.C b/client/app.C index 52509611be..df951254fe 100644 --- a/client/app.C +++ b/client/app.C @@ -293,10 +293,11 @@ int ACTIVE_TASK::start(bool first_time) { char *errorargs[] = {app_version->app_name,"","","",""}; LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, win_error, 0, (LPTSTR)&lpMsgBuf, 0, errorargs); + NULL, win_error, 0, (LPTSTR)&lpMsgBuf, 0, errorargs + ); // check for an error; if there is one, set error information for the currect result - if(win_error) { + if (win_error) { gstate.report_project_error(*result, win_error, (LPTSTR)&lpMsgBuf); LocalFree(lpMsgBuf); return -1; @@ -304,7 +305,7 @@ int ACTIVE_TASK::start(bool first_time) { fprintf(stdout, "CreateProcess: %s\n", (LPCTSTR)lpMsgBuf); LocalFree(lpMsgBuf); } - pid = process_info.dwProcessId; + pid = process_info.dwProcessId; pid_handle = process_info.hProcess; thread_handle = process_info.hThread; #else @@ -413,16 +414,20 @@ bool ACTIVE_TASK_SET::poll() { if (atp->state == PROCESS_ABORT_PENDING) { atp->state = PROCESS_ABORTED; atp->result->active_task_state = PROCESS_ABORTED; - gstate.report_project_error(*(atp->result), 0, "process was aborted\n"); + gstate.report_project_error( + *(atp->result), 0, "process was aborted\n" + ); } else { atp->state = PROCESS_EXITED; atp->exit_status = exit_code; atp->result->exit_status = atp->exit_status; atp->result->active_task_state = PROCESS_EXITED; //if a nonzero error code, then report it - if(exit_code) { - gstate.report_project_error(*(atp->result),0, - "process exited with a non zero exit code\n"); + if (exit_code) { + gstate.report_project_error( + *(atp->result), 0, + "process exited with a non zero exit code\n" + ); } } CloseHandle(atp->pid_handle); @@ -451,7 +456,9 @@ bool ACTIVE_TASK_SET::poll() { if (atp->state == PROCESS_ABORT_PENDING) { atp->state = PROCESS_ABORTED; atp->result->active_task_state = PROCESS_ABORTED; - gstate.report_project_error(*(atp->result),0,"process was aborted\n"); + gstate.report_project_error( + *(atp->result), 0, "process was aborted\n" + ); } else { if (WIFEXITED(stat)) { atp->state = PROCESS_EXITED; @@ -461,8 +468,10 @@ bool ACTIVE_TASK_SET::poll() { // If exit_status != 0, then we don't need to upload the // files for the result of this app if(atp->exit_status) { - gstate.report_project_error(*(atp->result),0, - "process exited with a nonzero exit code\n"); + gstate.report_project_error( + *(atp->result), 0, + "process exited with a nonzero exit code\n" + ); } if (log_flags.task_debug) printf("process exited: status %d\n", atp->exit_status); } else if (WIFSIGNALED(stat)) { @@ -470,11 +479,13 @@ bool ACTIVE_TASK_SET::poll() { atp->signal = WTERMSIG(stat); atp->result->signal = atp->signal; atp->result->active_task_state = PROCESS_WAS_SIGNALED; - gstate.report_project_error(*(atp->result),0,"process was signaled\n"); + gstate.report_project_error( + *(atp->result), 0, "process was signaled\n" + ); if (log_flags.task_debug) printf("process was signaled: %d\n", atp->signal); } else { atp->state = PROCESS_EXIT_UNKNOWN; - atp->result->state = PROCESS_EXIT_UNKNOWN; + atp->result->state = PROCESS_EXIT_UNKNOWN; } } @@ -517,7 +528,7 @@ bool ACTIVE_TASK::read_stderr_file() { n = fread(result->stderr_out, 1, sizeof(result->stderr_out), f); result->stderr_out[n] = 0; fclose(f); - return true; + return true; } return false; } @@ -634,7 +645,10 @@ int ACTIVE_TASK_SET::restart_tasks() { if (retval) { fprintf(stderr, "ACTIVE_TASKS::restart_tasks(); restart failed: %d\n", retval); atp->result->active_task_state = PROCESS_COULDNT_START; - gstate.report_project_error(*(atp->result),retval,"Couldn't restart the app for this result.\n"); + gstate.report_project_error( + *(atp->result), retval, + "Couldn't restart the app for this result.\n" + ); active_tasks.erase(iter); } else { iter++; diff --git a/client/cs_files.C b/client/cs_files.C index 2f5bb8327e..a3d86724ae 100644 --- a/client/cs_files.C +++ b/client/cs_files.C @@ -104,26 +104,22 @@ bool CLIENT_STATE::handle_pers_file_xfers() { bool action = false; int retval; + // Look for FILE_INFOs for which we should start a transfer, + // and make PERS_FILE_XFERs for them + // for (i=0; ipers_file_xfer; if (pfx) continue; if (!fip->generated_locally && fip->status == FILE_NOT_PRESENT) { - - // Set up the persistent file transfer object. - // This will start the download when there is available bandwidth - // pfx = new PERS_FILE_XFER; pfx->init(fip, false); fip->pers_file_xfer = pfx; retval = pers_xfers->insert(fip->pers_file_xfer); - //if (retval) gstate.report_project_error( *fip->result, retval, "" ); // ******* + // TODO: return error? action = true; } else if (fip->upload_when_present && fip->status == FILE_PRESENT && !fip->uploaded) { - // Set up the persistent file transfer object. - // This will start the upload when there is available bandwidth - // pfx = new PERS_FILE_XFER; pfx->init(fip, true); fip->pers_file_xfer = pfx; @@ -132,17 +128,21 @@ bool CLIENT_STATE::handle_pers_file_xfers() { } } - for (i=0; ipers_file_xfers.size(); i++) { - pfx = pers_xfers->pers_file_xfers[i]; + // Scan existing PERS_FILE_XFERs, looking for those that are done, + // and deleting them + // + vector::iterator iter; + iter = pers_xfers->pers_file_xfers.begin(); + while (iter != pers_xfers->pers_file_xfers.end()) { + pfx = *iter; // If the transfer finished, remove the PERS_FILE_XFER object // from the set and delete it // if (pfx->xfer_done) { pfx->fip->pers_file_xfer = NULL; - pers_xfers->remove(pfx); + iter = pers_xfers->pers_file_xfers.erase(iter); delete pfx; - i--; action = true; } } diff --git a/todo b/todo index 7ca56d8107..d9a155582b 100755 --- a/todo +++ b/todo @@ -1,21 +1,6 @@ ----------------------- BUGS (arranged from high to low priority) ----------------------- -- Allow change of email address, with verification - proposed scheme: - user enters new email address X - system generates random string Y, - changes user email address to @X_Y - syntactically invalid; can distinguish - must make sure that this isn't displayed on web site - emails message to X containing Y - at web site, user enters Y - system verifies that email address is of form @X_Y; - changes email address to X - - Use this same scheme on account creation: - email is initially @X_Y; on first login, change to X - - multiple preference sets - Test suspend/resume functionality on Windows, no way to suspend/resume on UNIX @@ -30,8 +15,6 @@ BUGS (arranged from high to low priority) should there be a user control for this? - Client treats URL "maggie/ap/" different than URL "maggie/ap", though this isn't really a bug it might be good to fix anyway -- verify that if file xfer is interrupted, it resumes at right place - (and progress bar is correct) - make pie chart colors/labels easier to understand - need a way to refresh prefs from client - Client should display "Upload failed" and "Download failed" when failure occurs @@ -60,6 +43,8 @@ Messages from core client ----------------------- THINGS TO TEST (preferably with test scripts) ----------------------- +- verify that if file xfer is interrupted, it resumes at right place + (and progress bar is correct) - result reissue - WU failure: too many errors - WU failure: too many good results