8202353: os::readdir should use readdir instead of readdir_r

8202835: jfr/event/os/TestSystemProcess.java fails on missing events

Os::readdir uses POSIX readdir, drop buffer arg, fix JFR uses.

Reviewed-by: coleenp, tschatzl, bsrbnd
This commit is contained in:
Kim Barrett 2018-07-17 15:59:47 -04:00
parent f4723253b6
commit 9a9c824ece
22 changed files with 54 additions and 238 deletions

View file

@ -893,21 +893,14 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProc
}
int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
struct dirent* entry;
if (!is_valid()) {
return OS_ERR;
}
do {
entry = os::readdir(_dir, _entry);
if (entry == NULL) {
// error
_valid = false;
return OS_ERR;
}
_entry = os::readdir(_dir);
if (_entry == NULL) {
// reached end
// Error or reached end. Could use errno to distinguish those cases.
_valid = false;
return OS_ERR;
}
@ -929,11 +922,8 @@ bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
}
SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
if (_entry != NULL) {
FREE_C_HEAP_ARRAY(char, _entry);
}
if (_dir != NULL) {
closedir(_dir);
os::closedir(_dir);
}
}