mirror of https://github.com/BOINC/boinc.git
Client: Rework write_state_file logic to always retry on error, suppress intermediate warnings
svn path=/trunk/boinc/; revision=14893
This commit is contained in:
parent
68ee073311
commit
b5e838b00e
|
@ -498,120 +498,101 @@ int CLIENT_STATE::write_state_file() {
|
|||
miof.init_mfile(&mf);
|
||||
ret1 = write_state(miof);
|
||||
ret2 = mf.close();
|
||||
if ((!ret1) && (!ret2)) break;
|
||||
if (ret1) {
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Couldn't write state file: %s", boincerror(retval)
|
||||
);
|
||||
}
|
||||
if (attempt < MAX_STATE_FILE_WRITE_ATTEMPTS) continue;
|
||||
return ret1;
|
||||
}
|
||||
if (ret2) {
|
||||
if (attempt < MAX_STATE_FILE_WRITE_ATTEMPTS) continue;
|
||||
return ret2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (ret1) return ret1;
|
||||
if (ret2) return ret2;
|
||||
|
||||
for (attempt=1; attempt<=MAX_STATE_FILE_WRITE_ATTEMPTS; attempt++) {
|
||||
if (attempt > 1) boinc_sleep(1.0);
|
||||
|
||||
// only attempt to rename the current state file if it exists.
|
||||
//
|
||||
if (boinc_file_exists(STATE_FILE_NAME)) {
|
||||
if (boinc_file_exists(STATE_FILE_PREV)) {
|
||||
// only attempt to rename the current state file if it exists.
|
||||
//
|
||||
if (boinc_file_exists(STATE_FILE_NAME)) {
|
||||
if (boinc_file_exists(STATE_FILE_PREV)) {
|
||||
for (attempt=1; attempt<=MAX_STATE_FILE_WRITE_ATTEMPTS; attempt++) {
|
||||
if (attempt > 1) boinc_sleep(1.0);
|
||||
retval = boinc_delete_file(STATE_FILE_PREV);
|
||||
if (retval) {
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
#ifdef _WIN32
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't delete previous state file; %s",
|
||||
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
||||
);
|
||||
#else
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't delete previous state file; error %d: %s",
|
||||
errno, strerror(errno)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
if (attempt < MAX_STATE_FILE_WRITE_ATTEMPTS) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (attempt=1; attempt<=MAX_STATE_FILE_WRITE_ATTEMPTS; attempt++) {
|
||||
if (attempt > 1) boinc_sleep(1.0);
|
||||
|
||||
if (boinc_file_exists(STATE_FILE_NAME)) {
|
||||
retval = boinc_rename(STATE_FILE_NAME, STATE_FILE_PREV);
|
||||
if (retval) {
|
||||
if (!retval) break;
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
#ifdef _WIN32
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename current state file to previous state file; %s",
|
||||
"Can't delete previous state file; %s",
|
||||
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
||||
);
|
||||
#else
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"rename current state file to previous state file returned error %d: %s",
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't delete previous state file; error %d: %s",
|
||||
errno, strerror(errno)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
if (attempt < MAX_STATE_FILE_WRITE_ATTEMPTS) continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (attempt=1; attempt<=MAX_STATE_FILE_WRITE_ATTEMPTS; attempt++) {
|
||||
if (attempt > 1) boinc_sleep(1.0);
|
||||
retval = boinc_rename(STATE_FILE_NAME, STATE_FILE_PREV);
|
||||
if (!retval) break;
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
#ifdef _WIN32
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename current state file to previous state file; %s",
|
||||
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
||||
);
|
||||
#else
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"rename current state file to previous state file returned error %d: %s",
|
||||
errno, strerror(errno)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (attempt=1; attempt<=MAX_STATE_FILE_WRITE_ATTEMPTS; attempt++) {
|
||||
if (attempt > 1) boinc_sleep(1.0);
|
||||
|
||||
retval = boinc_rename(STATE_FILE_NEXT, STATE_FILE_NAME);
|
||||
if (log_flags.state_debug) {
|
||||
msg_printf(0, MSG_INFO,
|
||||
"[status_debug] CLIENT_STATE::write_state_file(): Done writing state file"
|
||||
);
|
||||
}
|
||||
if (retval) {
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
if (!retval) return 0;
|
||||
if ((attempt == MAX_STATE_FILE_WRITE_ATTEMPTS) || log_flags.state_debug) {
|
||||
#ifdef _WIN32
|
||||
if (retval == ERROR_ACCESS_DENIED) {
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename state file; access denied; check file and directory permissions"
|
||||
);
|
||||
} else {
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename state file; %s",
|
||||
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
||||
);
|
||||
}
|
||||
#elif defined (__APPLE__)
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename %s to %s; check file and directory permissions\n"
|
||||
"rename returned error %d: %s",
|
||||
STATE_FILE_NEXT, STATE_FILE_NAME, errno, strerror(errno)
|
||||
if (retval == ERROR_ACCESS_DENIED) {
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename state file; access denied; check file and directory permissions"
|
||||
);
|
||||
} else {
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename state file; %s",
|
||||
windows_error_string(win_error_msg, sizeof(win_error_msg))
|
||||
);
|
||||
if (log_flags.state_debug) {
|
||||
system("ls -al /Library/Application\\ Support/BOINC\\ Data/client*.*");
|
||||
}
|
||||
#else
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename %s to %s; check file and directory permissions",
|
||||
STATE_FILE_NEXT, STATE_FILE_NAME
|
||||
);
|
||||
#endif
|
||||
}
|
||||
if (attempt < MAX_STATE_FILE_WRITE_ATTEMPTS) continue;
|
||||
return ERR_RENAME;
|
||||
#elif defined (__APPLE__)
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename %s to %s; check file and directory permissions\n"
|
||||
"rename returned error %d: %s",
|
||||
STATE_FILE_NEXT, STATE_FILE_NAME, errno, strerror(errno)
|
||||
);
|
||||
if (log_flags.state_debug) {
|
||||
system("ls -al /Library/Application\\ Support/BOINC\\ Data/client*.*");
|
||||
}
|
||||
#else
|
||||
msg_printf(0, MSG_USER_ERROR,
|
||||
"Can't rename %s to %s; check file and directory permissions",
|
||||
STATE_FILE_NEXT, STATE_FILE_NAME
|
||||
);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return ERR_RENAME;
|
||||
}
|
||||
|
||||
int CLIENT_STATE::write_state(MIOFILE& f) {
|
||||
|
|
Loading…
Reference in New Issue