- client: fix memory leak when reading stderr of completed job.

This caused 128KB + size of stderr loss for each job.
- client: print error message if reading stderr fails
    (e.g. because of malloc failure)


svn path=/trunk/boinc/; revision=24336
This commit is contained in:
David Anderson 2011-10-05 22:16:02 +00:00
parent f304e50691
commit c7e505dc81
3 changed files with 27 additions and 6 deletions

View File

@ -6821,3 +6821,13 @@ Rom 5 Oct 2011
lib/
diagnostics.cpp
David 5 Oct
- client: fix memory leak when reading stderr of completed job.
This caused 128KB + size of stderr loss for each job.
- client: print error message if reading stderr fails
(e.g. because of malloc failure)
client/
app.h
app_control.cpp

View File

@ -244,7 +244,7 @@ struct ACTIVE_TASK {
bool get_app_status_msg();
bool get_trickle_up_msg();
double est_dur();
bool read_stderr_file();
int read_stderr_file();
bool finish_file_present();
bool temporary_exit_file_present(double&);
void init_app_init_data(APP_INIT_DATA&);

View File

@ -490,7 +490,12 @@ void ACTIVE_TASK::handle_exited_app(int stat) {
if (!will_restart) {
copy_output_files();
read_stderr_file();
int retval = read_stderr_file();
if (retval) {
msg_printf(result->project, MSG_INTERNAL_ERROR,
"read_stderr_file(): %s", boincerror(retval)
);
}
client_clean_out_dir(slot_dir, "handle_exited_app()");
clear_schedule_backoffs(this);
// clear scheduling backoffs of jobs waiting for GPU
@ -772,7 +777,7 @@ int ACTIVE_TASK::abort_task(int exit_status, const char* msg) {
// check for the stderr file, copy to result record
//
bool ACTIVE_TASK::read_stderr_file() {
int ACTIVE_TASK::read_stderr_file() {
char* buf1, *buf2;
char path[256];
@ -781,16 +786,22 @@ bool ACTIVE_TASK::read_stderr_file() {
//
int max_len = 63*1024;
sprintf(path, "%s/%s", slot_dir, STDERR_FILE);
if (!boinc_file_exists(path)) return false;
if (!boinc_file_exists(path)) return 0;
if (read_file_malloc(path, buf1, max_len, !config.stderr_head)) {
return false;
return ERR_MALLOC;
}
buf2 = (char*)malloc(2*max_len);
if (!buf2) {
free(buf1);
return ERR_MALLOC;
}
non_ascii_escape(buf1, buf2, 2*max_len);
result->stderr_out += "<stderr_txt>\n";
result->stderr_out += buf2;
result->stderr_out += "\n</stderr_txt>\n";
return true;
free(buf1);
free(buf2);
return 0;
}
// tell a running app to reread project preferences.