提交 a66be7b9 编写于 作者: T thartmann

8007993: hotspot.log w/ enabled LogCompilation can be an invalid XML

Summary: Open compilation log files in write-mode and close before deletion attempt.
Reviewed-by: vlivanov
上级 7ba6c46b
...@@ -1845,7 +1845,7 @@ void CompileBroker::init_compiler_thread_log() { ...@@ -1845,7 +1845,7 @@ void CompileBroker::init_compiler_thread_log() {
os::file_separator(), thread_id, os::current_process_id()); os::file_separator(), thread_id, os::current_process_id());
} }
fp = fopen(file_name, "at"); fp = fopen(file_name, "wt");
if (fp != NULL) { if (fp != NULL) {
if (LogCompilation && Verbose) { if (LogCompilation && Verbose) {
tty->print_cr("Opening compilation log %s", file_name); tty->print_cr("Opening compilation log %s", file_name);
......
...@@ -55,8 +55,10 @@ CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id) ...@@ -55,8 +55,10 @@ CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id)
} }
CompileLog::~CompileLog() { CompileLog::~CompileLog() {
delete _out; delete _out; // Close fd in fileStream::~fileStream()
_out = NULL; _out = NULL;
// Remove partial file after merging in CompileLog::finish_log_on_error
unlink(_file);
FREE_C_HEAP_ARRAY(char, _identities, mtCompiler); FREE_C_HEAP_ARRAY(char, _identities, mtCompiler);
FREE_C_HEAP_ARRAY(char, _file, mtCompiler); FREE_C_HEAP_ARRAY(char, _file, mtCompiler);
} }
...@@ -268,10 +270,9 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) ...@@ -268,10 +270,9 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
} }
file->print_raw_cr("</compilation_log>"); file->print_raw_cr("</compilation_log>");
close(partial_fd); close(partial_fd);
unlink(partial_file);
} }
CompileLog* next_log = log->_next; CompileLog* next_log = log->_next;
delete log; delete log; // Removes partial file
log = next_log; log = next_log;
} }
_first = NULL; _first = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册