src/os/linux/vm/perfMemory_linux.cpp

changeset 9711
0f2fe7d37d8c
parent 9507
7e72702243a4
child 9756
2be326848943
child 9858
b985cbb00e68
equal deleted inserted replaced
9710:5d306df084eb 9711:0f2fe7d37d8c
531 // open the directory and check if the file for the given vmid exists. 531 // open the directory and check if the file for the given vmid exists.
532 // The file with the expected name and the latest creation date is used 532 // The file with the expected name and the latest creation date is used
533 // to determine the user name for the process id. 533 // to determine the user name for the process id.
534 // 534 //
535 struct dirent* dentry; 535 struct dirent* dentry;
536 char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
537 errno = 0; 536 errno = 0;
538 while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) { 537 while ((dentry = os::readdir(tmpdirp)) != NULL) {
539 538
540 // check if the directory entry is a hsperfdata file 539 // check if the directory entry is a hsperfdata file
541 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { 540 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
542 continue; 541 continue;
543 } 542 }
567 os::closedir(subdirp); 566 os::closedir(subdirp);
568 continue; 567 continue;
569 } 568 }
570 569
571 struct dirent* udentry; 570 struct dirent* udentry;
572 char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
573 errno = 0; 571 errno = 0;
574 while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) { 572 while ((udentry = os::readdir(subdirp)) != NULL) {
575 573
576 if (filename_to_pid(udentry->d_name) == vmid) { 574 if (filename_to_pid(udentry->d_name) == vmid) {
577 struct stat statbuf; 575 struct stat statbuf;
578 int result; 576 int result;
579 577
613 611
614 FREE_C_HEAP_ARRAY(char, filename, mtInternal); 612 FREE_C_HEAP_ARRAY(char, filename, mtInternal);
615 } 613 }
616 } 614 }
617 os::closedir(subdirp); 615 os::closedir(subdirp);
618 FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
619 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal); 616 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
620 } 617 }
621 os::closedir(tmpdirp); 618 os::closedir(tmpdirp);
622 FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
623 619
624 return(oldest_user); 620 return(oldest_user);
625 } 621 }
626 622
627 // return the name of the user that owns the JVM indicated by the given vmid. 623 // return the name of the user that owns the JVM indicated by the given vmid.
696 // remove or create new files in this directory. The behavior of this 692 // remove or create new files in this directory. The behavior of this
697 // loop under these conditions is dependent upon the implementation of 693 // loop under these conditions is dependent upon the implementation of
698 // opendir/readdir. 694 // opendir/readdir.
699 // 695 //
700 struct dirent* entry; 696 struct dirent* entry;
701 char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
702
703 errno = 0; 697 errno = 0;
704 while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) { 698 while ((entry = os::readdir(dirp)) != NULL) {
705 699
706 pid_t pid = filename_to_pid(entry->d_name); 700 pid_t pid = filename_to_pid(entry->d_name);
707 701
708 if (pid == 0) { 702 if (pid == 0) {
709 703
736 errno = 0; 730 errno = 0;
737 } 731 }
738 732
739 // close the directory and reset the current working directory 733 // close the directory and reset the current working directory
740 close_directory_secure_cwd(dirp, saved_cwd_fd); 734 close_directory_secure_cwd(dirp, saved_cwd_fd);
741
742 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
743 } 735 }
744 736
745 // make the user specific temporary directory. Returns true if 737 // make the user specific temporary directory. Returns true if
746 // the directory exists and is secure upon return. Returns false 738 // the directory exists and is secure upon return. Returns false
747 // if the directory exists but is either a symlink, is otherwise 739 // if the directory exists but is either a symlink, is otherwise

mercurial