app stderr fix

svn path=/trunk/boinc/; revision=1609
This commit is contained in:
Eric Heien 2003-06-27 23:13:15 +00:00
parent 45b0426de5
commit cc284ffd81
4 changed files with 20 additions and 27 deletions

View File

@ -684,15 +684,20 @@ int ACTIVE_TASK::abort() {
// check for the stderr file, copy to result record
//
bool ACTIVE_TASK::read_stderr_file() {
char stderr_file[MAX_BLOB_LEN];
char path[256];
int n;
sprintf(path, "%s%s%s", slot_dir, PATH_SEPARATOR, STDERR_FILE);
FILE* f = fopen(path, "r");
if (f) {
n = fread(result->stderr_out, 1, sizeof(result->stderr_out), f);
result->stderr_out[n] = 0;
n = fread(stderr_file, 1, sizeof(stderr_file), f);
fclose(f);
stderr_file[n-1] = '\0';
result->stderr_out += "<stderr_txt>\n";
result->stderr_out += stderr_file;
result->stderr_out += "\n</stderr_txt>\n";
result->stderr_out = result->stderr_out.substr(0,MAX_BLOB_LEN-1);
return true;
}
return false;

View File

@ -1550,16 +1550,11 @@ int CLIENT_STATE::report_result_error(
res.exit_status,
res.signal
);
if (strlen(res.stderr_out) + strlen(buf) < MAX_BLOB_LEN) {
strcat(res.stderr_out, buf );
}
res.stderr_out.append(buf);
if ((res.state == RESULT_FILES_DOWNLOADED) && err_num) {
sprintf(buf,"<couldnt_start>%d</couldnt_start>\n", err_num);
if (strlen(res.stderr_out) + strlen(buf) < MAX_BLOB_LEN) {
strcat(res.stderr_out, buf );
}
res.stderr_out.append(buf);
}
if (res.state == RESULT_NEW) {
@ -1572,9 +1567,7 @@ int CLIENT_STATE::report_result_error(
"</download_error>\n",
res.wup->input_files[i].file_info->name, failnum
);
if (strlen(res.stderr_out) + strlen(buf) < MAX_BLOB_LEN ) {
strcat( res.stderr_out, buf );
}
res.stderr_out.append(buf);
}
}
}
@ -1589,12 +1582,12 @@ int CLIENT_STATE::report_result_error(
"</upload_error>\n",
res.output_files[i].file_info->name, failnum
);
if (strlen(res.stderr_out) + strlen(buf) < MAX_BLOB_LEN ) {
strcat( res.stderr_out, buf );
}
res.stderr_out.append(buf);
}
}
}
res.stderr_out = res.stderr_out.substr(0,MAX_BLOB_LEN-1);
return 0;
}

View File

@ -737,7 +737,7 @@ void RESULT::clear() {
exit_status = 0;
active_task_state = 0;
signal = 0;
strcpy(stderr_out, "");
stderr_out = "";
app = NULL;
wup = NULL;
project = NULL;
@ -790,7 +790,7 @@ int RESULT::parse_state(FILE* in) {
else if (match_tag(buf, "<stderr_out>")) {
while (fgets(buf, 256, in)) {
if (match_tag(buf, "</stderr_out>")) break;
strcat(stderr_out, buf);
stderr_out.append(buf);
}
continue;
}
@ -813,17 +813,12 @@ int RESULT::write(FILE* out, bool to_server) {
final_cpu_time,
state
);
n = strlen(stderr_out);
n = stderr_out.length();
if (n) {
fprintf(out,
"<stderr_out>\n"
"%s",
stderr_out
);
fprintf(out, "<stderr_out>\n");
fprintf(out, stderr_out.c_str());
if (stderr_out[n-1] != '\n') fprintf(out, "\n");
fprintf(out,
"</stderr_out>\n"
);
fprintf(out, "</stderr_out>\n");
}
if (!to_server) {
if (server_ack) fprintf(out, " <server_ack/>\n");

View File

@ -221,7 +221,7 @@ struct RESULT {
int signal; // the signal caught by the active_task,
// defined only if active_task_state is PROCESS_SIGNALED
int active_task_state; // the state of the active task corresponding to this result
char stderr_out[MAX_BLOB_LEN];
string stderr_out;
APP* app;
WORKUNIT* wup;