8303937: Corrupted heap dumps due to missing retries for os::write()

Reviewed-by: cjplummer, dholmes
This commit is contained in:
Man Cao 2023-03-10 18:14:09 +00:00
parent 6f54eda4a4
commit bf16b5b988

View File

@ -55,10 +55,14 @@ char const* FileWriter::write_buf(char* buf, ssize_t size) {
assert(_fd >= 0, "Must be open");
assert(size > 0, "Must write at least one byte");
ssize_t n = os::write(_fd, buf, (uint) size);
while (size > 0) {
ssize_t n = os::write(_fd, buf, (uint) size);
if (n <= 0) {
return os::strerror(errno);
}
if (n <= 0) {
return os::strerror(errno);
buf += n;
size -= n;
}
return nullptr;