From 56492aaeac40337284392a330695e31f94394fd0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 6 Oct 2011 17:39:13 +0000 Subject: [PATCH] - client: fix bug in writing daily xfer history file svn path=/trunk/boinc/; revision=24341 --- checkin_notes | 9 ++++++++- client/main.cpp | 2 +- client/net_stats.cpp | 22 ++++++++++++++++------ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 8284eaf5e1..bb39381138 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6863,7 +6863,7 @@ David 5 Oct client/ pers_file_xfer.cpp -David 5 Oct +David 6 Oct - GUI RPC: add get_daily_xfer_history() RPC for getting the daily records of #bytes uploaded and downloaded @@ -6876,3 +6876,10 @@ David 5 Oct gui_rpc_server_ops.cpp net_stats.cpp,h main.cpp + +David 6 Oct + - client: fix bug in writing daily xfer history file + + client/ + main.cpp + net_stats.cpp diff --git a/client/main.cpp b/client/main.cpp index ffd462c2c6..c55a89ba0b 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -280,7 +280,7 @@ static int finalize() { #ifdef USE_WINSOCK if (WinsockCleanup()) { - log_message_error("Failed to cleanup the Windows Sockets interface"); + log_message_error("WinSockCleanup() failed"); return ERR_IO; } #endif diff --git a/client/net_stats.cpp b/client/net_stats.cpp index e7dba4597a..e5ccebe00d 100644 --- a/client/net_stats.cpp +++ b/client/net_stats.cpp @@ -378,7 +378,7 @@ int DAILY_XFER_HISTORY::write_xml(MIOFILE& out) { dx.write(out); } int n = out.printf("\n"); - if (n != 1) return ERR_FWRITE; + if (n <= 0) return ERR_FWRITE; return 0; } @@ -389,11 +389,21 @@ void DAILY_XFER_HISTORY::write_file() { mf.init_file(f); int retval = write_xml(mf); fclose(f); - if (!retval) { - retval = boinc_rename(TEMP_FILE_NAME, DAILY_XFER_HISTORY_FILENAME); - if (!retval) { - dirty = false; - } + if (retval) { + msg_printf(0, MSG_INTERNAL_ERROR, + "failed to write xfer history: %s", + boincerror(retval) + ); + return; + } + retval = boinc_rename(TEMP_FILE_NAME, DAILY_XFER_HISTORY_FILENAME); + if (retval) { + msg_printf(0, MSG_INTERNAL_ERROR, + "failed to rename xfer history file: %s", + boincerror(retval) + ); + } else { + dirty = false; } }