diff --git a/checkin_notes b/checkin_notes index 252738955b..8bd6a9234a 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3079,3 +3079,18 @@ David Jan 30 2003 sched/ db_dump.C handle_request.C + +Eric Feb 04, 2003 + - Cleaned up formatting of client_state.xml + - Added retry message to transfers tab of Windows client + - Added error catching for network transfer failures + + client/ + client_state.C + client_types.C + cs_files.C + http.C + pers_file_xfer.C,h + win/ + wingui.h + wingui_mainwindow.cpp,h diff --git a/client/client_state.C b/client/client_state.C index f11563b3fc..23aca41ad1 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -501,9 +501,6 @@ int CLIENT_STATE::parse_state_file() { if (fip->pers_file_xfer) { fip->pers_file_xfer->init(fip, fip->upload_when_present); retval = pers_xfers->insert( fip->pers_file_xfer ); - if (retval) { - // TODO: What should we do here? - } } } else { delete fip; diff --git a/client/client_types.C b/client/client_types.C index b96483842c..d36744e3ff 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -363,17 +363,17 @@ int FILE_INFO::write(FILE* out, bool to_server) { if (file_signature) fprintf(out," \n%s\n", file_signature); } for (i=0; i%s\n", urls[i].text); + fprintf(out, " %s\n", urls[i].text); } if (!to_server && pers_file_xfer) { pers_file_xfer->write(out); } if (!to_server) { if (signed_xml && xml_signature) { - fprintf(out, "\n%s\n", signed_xml); + fprintf(out, " \n%s \n", signed_xml); } if (xml_signature) { - fprintf(out, "\n%s\n", xml_signature); + fprintf(out, " \n%s \n", xml_signature); } } fprintf(out, "\n"); diff --git a/client/cs_files.C b/client/cs_files.C index b2399e89f3..9acaef8c66 100644 --- a/client/cs_files.C +++ b/client/cs_files.C @@ -142,6 +142,7 @@ bool CLIENT_STATE::handle_pers_file_xfers() { pfx->fip->pers_file_xfer = NULL; pers_xfers->remove(pfx); delete pfx; + i--; action = true; } } diff --git a/client/http.C b/client/http.C index 4b1affce39..22fb2c9d4a 100644 --- a/client/http.C +++ b/client/http.C @@ -545,7 +545,13 @@ bool HTTP_OP_SET::poll() { } break; case HTTP_STATE_REPLY_BODY: - if (htp->io_done) { + if (htp->error) { + action = true; + if (log_flags.http_debug) printf("net_xfer returned error %d\n", htp->error); + htp->http_op_state = HTTP_STATE_DONE; + htp->http_op_retval = htp->error; + } + else if (htp->io_done) { action = true; switch(htp->http_op_type) { case HTTP_OP_POST2: diff --git a/client/pers_file_xfer.C b/client/pers_file_xfer.C index e60c4b7946..dfaacbffd8 100644 --- a/client/pers_file_xfer.C +++ b/client/pers_file_xfer.C @@ -41,15 +41,19 @@ // For upload, try to upload the file to the first URL; // if that fails try the others. // -int PERS_FILE_XFER::init(FILE_INFO* f, bool is_file_upload) { - fxp = NULL; - fip = f; + +PERS_FILE_XFER::PERS_FILE_XFER() { nretry = 0; first_request_time = time(0); next_request_time = first_request_time; +} + +int PERS_FILE_XFER::init(FILE_INFO* f, bool is_file_upload) { + fxp = NULL; + fip = f; is_upload = is_file_upload; xfer_done = false; - time_so_far = 0; + time_so_far = 0; return 0; } @@ -93,8 +97,16 @@ bool PERS_FILE_XFER::start_xfer() { ); } else { retval = gstate.file_xfers->insert(file_xfer); - if (retval) return false; fxp = file_xfer; + if (retval) { + if (log_flags.file_xfer) { + printf( "file_xfer insert failed\n" ); + } + fxp->file_xfer_retval = retval; + handle_xfer_failure(aclock); + fxp = NULL; + return false; + } if (log_flags.file_xfer) { printf( "started %s of %s to %s at time: %s\n", @@ -123,18 +135,18 @@ bool PERS_FILE_XFER::poll(unsigned int now) { // See if it's time to try again. // if (now >= (unsigned int)next_request_time) { - bool ok = start_xfer(); - last_time = dtime(); - return ok; + bool ok = start_xfer(); + last_time = dtime(); + return ok; } else { return false; } } - if(dtime() - last_time <= 2) { - time_so_far += dtime() - last_time; - } - last_time = dtime(); + if(dtime() - last_time <= 2) { + time_so_far += dtime() - last_time; + } + last_time = dtime(); if (fxp->file_xfer_done) { if (log_flags.file_xfer) { @@ -197,18 +209,18 @@ void PERS_FILE_XFER::handle_xfer_failure(unsigned int cur_time) { if (fxp->file_xfer_retval == HTTP_STATUS_RANGE_REQUEST_ERROR) { fip->delete_file(); } - + retry_and_backoff(cur_time); // See if it's time to give up on the persistent file xfer // if ((cur_time - first_request_time) > gstate.giveup_after) { // Set the associated files status to a ERR_GIVEUP_DOWNLOAD and ERR_GIVEUP_UPLOAD failure - if(is_upload) - fip->status = ERR_GIVEUP_UPLOAD; - else - fip->status = ERR_GIVEUP_DOWNLOAD; - xfer_done = true; + if(is_upload) + fip->status = ERR_GIVEUP_UPLOAD; + else + fip->status = ERR_GIVEUP_DOWNLOAD; + xfer_done = true; } if (log_flags.file_xfer_debug) { printf("Error: transfer failure for %s: %d\n", fip->name, fip->status); @@ -241,8 +253,8 @@ int PERS_FILE_XFER::retry_and_backoff(unsigned int cur_time) { } if (log_flags.file_xfer_debug) { printf( - "exponential back off is %d, current_time is %s\n", (int) exp_backoff,asctime( newtime ) - ); + "exponential back off is %d, current_time is %s\n", (int) exp_backoff,asctime( newtime ) + ); } return 0; } diff --git a/client/pers_file_xfer.h b/client/pers_file_xfer.h index ee45c213a0..5b71c5bdd9 100644 --- a/client/pers_file_xfer.h +++ b/client/pers_file_xfer.h @@ -35,12 +35,12 @@ #define PERS_RETRY_DELAY_MIN 60 // 1 minute #define PERS_RETRY_DELAY_MAX (60*60*4) // 4 hours -#define PERS_GIVEUP (60*60*24*7*2) // 2 weeks +#define PERS_GIVEUP (60*60*24*7*2) // 2 weeks #ifdef DEBUG -#define PERS_RETRY_DELAY_MIN 1 -#define PERS_RETRY_DELAY_MAX 30 -#define PERS_GIVEUP 30 +#define PERS_RETRY_DELAY_MIN 1 +#define PERS_RETRY_DELAY_MAX 30 +#define PERS_GIVEUP 30 #endif // give up on xfer if this time elapses since last byte xferred @@ -48,15 +48,16 @@ class PERS_FILE_XFER { int nretry; // # of retries so far int first_request_time; // UNIX time of first file request - int next_request_time; // UNIX time to next retry the file request bool is_upload; public: + int next_request_time; // UNIX time to next retry the file request double last_time, time_so_far; bool xfer_done; FILE_XFER* fxp; // nonzero if file xfer in progress FILE_INFO* fip; + PERS_FILE_XFER(); int init(FILE_INFO*, bool is_file_upload); bool poll(unsigned int now); void handle_xfer_failure(unsigned int cur_time); diff --git a/client/win/wingui.h b/client/win/wingui.h index 5e136401d1..76a4cdbd26 100755 --- a/client/win/wingui.h +++ b/client/win/wingui.h @@ -34,6 +34,7 @@ #include "log_flags.h" #include "client_state.h" #include "account.h" +#include "error_numbers.h" #include "resource.h" #include "util.h" #include "win_net.h" diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index ce94c02637..e9eed5dd33 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -33,7 +33,7 @@ char g_szTabItems[MAX_TABS][256] = { char g_szColumnTitles[MAX_LIST_ID][MAX_COLS][256] = { {"Project", "Account", "Total Credit", "Avg. Credit", "Resource Share", "", ""}, {"Project", "Application", "Name", "CPU time", "Progress", "To Completion", "Status"}, - {"Project", "File", "Progress", "Size", "Time", "Direction", ""}, + {"Project", "File", "Progress", "Size", "Time", "Status", ""}, {"Project", "Time", "Message", "", "", "", ""} }; @@ -54,8 +54,11 @@ char g_szMiscItems[MAX_MISC_STR][256] = { "Acknowledged", "Error: invalid state", "Completed", - "Upload", - "Download" + "Uploading", + "Downloading", + "Retry in", + "Download failed", + "Upload failed" }; ///////////////////////////////////////////////////////////////////////// @@ -336,8 +339,23 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) strBuf.Format("%0.2d:%0.2d:%0.2d", xhour, xmin, xsec); m_XferListCtrl.SetItemText(i, 4, strBuf.GetBuffer(0)); - // direction - m_XferListCtrl.SetItemText(i, 5, fi->fip->generated_locally?g_szMiscItems[8]:g_szMiscItems[9]); + // status + if (fi->next_request_time > time(0)) { + double xtime = fi->next_request_time-time(0); + int xhour = (int)(xtime / (60 * 60)); + int xmin = (int)(xtime / 60) % 60; + int xsec = (int)(xtime) % 60; + strBuf.Format("%s %0.2d:%0.2d:%0.2d", g_szMiscItems[10], xhour, xmin, xsec); + m_XferListCtrl.SetItemText(i, 5, strBuf); + } else if (fi->fip->status == ERR_GIVEUP_DOWNLOAD) { + strBuf.Format(g_szMiscItems[11]); + m_XferListCtrl.SetItemText(i, 5, strBuf); + } else if (fi->fip->status == ERR_GIVEUP_UPLOAD) { + strBuf.Format(g_szMiscItems[12]); + m_XferListCtrl.SetItemText(i, 5, strBuf); + } else { + m_XferListCtrl.SetItemText(i, 5, fi->fip->generated_locally?g_szMiscItems[8]:g_szMiscItems[9]); + } } m_XferListCtrl.SetRedraw(TRUE); diff --git a/client/win/wingui_mainwindow.h b/client/win/wingui_mainwindow.h index 4f8c49c0b2..e396ef9ed8 100755 --- a/client/win/wingui_mainwindow.h +++ b/client/win/wingui_mainwindow.h @@ -66,7 +66,8 @@ #define MAX_TABS 5 #define MAX_USAGE_STR 5 -#define MAX_MISC_STR 10 +#define MAX_MISC_STR 13 + ////////// // class: CMyApp diff --git a/todo b/todo index e1d213cec1..0252b88b05 100755 --- a/todo +++ b/todo @@ -29,9 +29,11 @@ BUGS (arranged from high to low priority) - client died quickly on Mandrake 9.0 linux (unconfirmed) - 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 - columns expand when window expands - Download speed is not as fast as it should be - Result status should say "downloading files", "uploading files", etc. +- Change vector removal routines to use an iterator ----------------------- HIGH-PRIORITY (should do for beta test)