1.1 --- a/src/share/vm/jfr/recorder/repository/jfrRepository.cpp Fri Dec 06 12:42:29 2019 +0100 1.2 +++ b/src/share/vm/jfr/recorder/repository/jfrRepository.cpp Tue Jun 16 11:03:04 2020 +0800 1.3 @@ -147,10 +147,10 @@ 1.4 iso8601_to_date_time(buffer); 1.5 } 1.6 1.7 -static jlong file_size(fio_fd fd) { 1.8 +static int64_t file_size(fio_fd fd) { 1.9 assert(fd != invalid_fd, "invariant"); 1.10 - const jlong current_offset = os::current_file_offset(fd); 1.11 - const jlong size = os::lseek(fd, 0, SEEK_END); 1.12 + const int64_t current_offset = os::current_file_offset(fd); 1.13 + const int64_t size = os::lseek(fd, 0, SEEK_END); 1.14 os::seek_to_file_offset(fd, current_offset); 1.15 return size; 1.16 } 1.17 @@ -218,7 +218,7 @@ 1.18 if (invalid_fd == entry_fd) { 1.19 return NULL; 1.20 } 1.21 - const jlong entry_size = file_size(entry_fd); 1.22 + const int64_t entry_size = file_size(entry_fd); 1.23 os::close(entry_fd); 1.24 if (0 == entry_size) { 1.25 return NULL; 1.26 @@ -260,6 +260,7 @@ 1.27 } 1.28 } 1.29 #endif 1.30 + 1.31 bool RepositoryIterator::has_next() const { 1.32 return (_files != NULL && _iterator < _files->length()); 1.33 } 1.34 @@ -275,21 +276,26 @@ 1.35 if (file_copy_block == NULL) { 1.36 return; 1.37 } 1.38 - jlong bytes_written_total = 0; 1.39 + int64_t bytes_written_total = 0; 1.40 while (iterator.has_next()) { 1.41 fio_fd current_fd = invalid_fd; 1.42 const char* const fqn = iterator.next(); 1.43 if (fqn != NULL) { 1.44 current_fd = open_existing(fqn); 1.45 if (current_fd != invalid_fd) { 1.46 - const jlong current_filesize = file_size(current_fd); 1.47 + const int64_t current_filesize = file_size(current_fd); 1.48 assert(current_filesize > 0, "invariant"); 1.49 - jlong bytes_read = 0; 1.50 - jlong bytes_written = 0; 1.51 + int64_t bytes_read = 0; 1.52 + int64_t bytes_written = 0; 1.53 while (bytes_read < current_filesize) { 1.54 - bytes_read += (jlong)os::read_at(current_fd, file_copy_block, size_of_file_copy_block, bytes_read); 1.55 - assert(bytes_read - bytes_written <= (jlong)size_of_file_copy_block, "invariant"); 1.56 - bytes_written += (jlong)os::write(emergency_fd, file_copy_block, bytes_read - bytes_written); 1.57 + const ssize_t read_result = os::read_at(current_fd, file_copy_block, size_of_file_copy_block, bytes_read); 1.58 + if (-1 == read_result) { 1.59 + if (LogJFR) tty->print_cr("Unable to recover JFR data"); 1.60 + break; 1.61 + } 1.62 + bytes_read += (int64_t)read_result; 1.63 + assert(bytes_read - bytes_written <= (int64_t)size_of_file_copy_block, "invariant"); 1.64 + bytes_written += (int64_t)os::write(emergency_fd, file_copy_block, bytes_read - bytes_written); 1.65 assert(bytes_read == bytes_written, "invariant"); 1.66 } 1.67 os::close(current_fd); 1.68 @@ -468,6 +474,6 @@ 1.69 return _chunkwriter->open(); 1.70 } 1.71 1.72 -size_t JfrRepository::close_chunk(jlong metadata_offset) { 1.73 +size_t JfrRepository::close_chunk(int64_t metadata_offset) { 1.74 return _chunkwriter->close(metadata_offset); 1.75 }