- lib/filesys: do timed retry of delete/rename on Unix as well as Win

- client: sleep 1 sec (not 60) before retry statefile write
- client: parse <credit> in workunit XML
- scheduler: better error messages if insert_wu_tags() fails

api/
    graphics2_unix.C
client/
    client_state.C
    client_types.C
lib/
    filesys.C
sched/
    sched_send.C

svn path=/trunk/boinc/; revision=12720
This commit is contained in:
David Anderson 2007-05-23 03:55:53 +00:00
parent 4f7daa6e1e
commit 2fcd2cb7d5
6 changed files with 66 additions and 41 deletions

View File

@ -25,20 +25,6 @@ static APP_INIT_DATA aid;
bool fullscreen;
static void get_window_title(APP_INIT_DATA& aid, char* buf, int len) {
if (aid.app_version) {
snprintf(buf, len,
"%s version %.2f [workunit: %s]",
aid.app_name, aid.app_version/100.0, aid.wu_name
);
} else {
snprintf(buf, len,
"%s [workunit: %s]",
aid.app_name, aid.wu_name
);
}
}
static void close_window() {
exit(0);
}

View File

@ -5203,3 +5203,19 @@ Charlie 22 May 2007
setupForBOINC.sh
boinc.xcodeproj/
project.pbxproj
David 22 May 2007
- lib/filesys: do timed retry of delete/rename on Unix as well as Win
- client: sleep 1 sec (not 60) before retry statefile write
- client: parse <credit> in workunit XML
- scheduler: better error messages if insert_wu_tags() fails
api/
graphics2_unix.C
client/
client_state.C
client_types.C
lib/
filesys.C
sched/
sched_send.C

View File

@ -528,7 +528,7 @@ bool CLIENT_STATE::poll_slow_events() {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Couldn't write state file: %s", boincerror(retval)
);
boinc_sleep(60.0);
boinc_sleep(1.0);
// if we can't write the state file twice in a row, something's hosed;
// better to not keep trying

View File

@ -1206,6 +1206,7 @@ int FILE_REF::write(MIOFILE& out) {
int WORKUNIT::parse(MIOFILE& in) {
char buf[4096];
FILE_REF file_ref;
double dtemp;
strcpy(name, "");
strcpy(app_name, "");
@ -1258,6 +1259,8 @@ int WORKUNIT::parse(MIOFILE& in) {
input_files.push_back(file_ref);
continue;
}
// unused stuff
else if (parse_double(buf, "<credit>", dtemp)) continue;
else {
if (log_flags.unparsed_xml) {
msg_printf(0, MSG_INFO,

View File

@ -247,6 +247,19 @@ DirScanner::~DirScanner() {
#endif
}
static int boinc_delete_file_aux(const char* path) {
#ifdef _WIN32
if (DeleteFile(path)) return 0;
return GetLastError();
#else
int retval = unlink(path);
if (retval && g_use_sandbox && (errno == EACCES)) {
// We may not have permission to read subdirectories created by projects
return remove_project_owned_file_or_dir(path);
}
return retval;
#endif
}
// Delete the file located at path
//
@ -256,21 +269,15 @@ int boinc_delete_file(const char* path) {
if (!boinc_file_exists(path)) {
return 0;
}
#ifdef _WIN32
double start = dtime();
do {
if (DeleteFile(path)) break;
retval = GetLastError();
boinc_sleep(drand()); // avoid lockstep
} while (dtime() < start + RETRY_INTERVAL);
#else
retval = unlink(path);
if (retval && g_use_sandbox && (errno == EACCES)) {
// We may not have permission to read subdirectories created by projects
return remove_project_owned_file_or_dir(path);
retval = boinc_delete_file_aux(path);
if (retval) {
double start = dtime();
do {
boinc_sleep(drand()*2); // avoid lockstep
retval = boinc_delete_file_aux(path);
if (!retval) break;
} while (dtime() < start + RETRY_INTERVAL);
}
return retval;
#endif
if (retval) {
safe_strcpy(boinc_failed_file, path);
return ERR_UNLINK;
@ -408,6 +415,7 @@ FILE* boinc_fopen(const char* path, const char* mode) {
//
if (!f) {
for (int i=0; i<5; i++) {
boinc_sleep(drand());
if (errno != EINTR) break;
f = fopen(path, mode);
if (f) break;
@ -463,22 +471,31 @@ int boinc_copy(const char* orig, const char* newf) {
#endif
}
int boinc_rename(const char* old, const char* newf) {
static int boinc_rename_aux(const char* old, const char* newf) {
#ifdef _WIN32
int retval=0;
boinc_delete_file(newf);
double start = dtime();
do {
if (MoveFile(old, newf)) break;
retval = GetLastError();
boinc_sleep(drand()*2); // avoid lockstep
} while (dtime() < start + RETRY_INTERVAL);
return retval;
if (MoveFile(old, newf)) return 0;
return GetLastError();
#else
return rename(old, newf);
#endif
}
int boinc_rename(const char* old, const char* newf) {
int retval=0;
retval = boinc_rename_aux(old, newf);
if (retval) {
double start = dtime();
do {
boinc_sleep(drand()*2); // avoid lockstep
retval = boinc_rename_aux(old, newf);
if (!retval) break;
} while (dtime() < start + RETRY_INTERVAL);
}
return retval;
}
int boinc_mkdir(const char* path) {
if (is_dir(path)) return 0;
#ifdef _WIN32

View File

@ -444,8 +444,9 @@ int insert_after(char* buffer, const char* after, const char* text) {
char temp[LARGE_BLOB_SIZE];
if (strlen(buffer) + strlen(text) > LARGE_BLOB_SIZE-1) {
log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,
"insert_after: overflow\n"
log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,
"insert_after: overflow: %d %d\n",
strlen(buffer), strlen(text)
);
return ERR_BUFFER_OVERFLOW;
}
@ -567,7 +568,9 @@ int add_wu_to_reply(
wu2 = wu; // make copy since we're going to modify its XML field
retval = insert_wu_tags(wu2, *app);
if (retval) {
log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL, "insert_wu_tags failed\n");
log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,
"insert_wu_tags failed %d\n", retval
);
return retval;
}
wu3=wu2;