src/os/aix/vm/perfMemory_aix.cpp

changeset 9711
0f2fe7d37d8c
parent 9507
7e72702243a4
equal deleted inserted replaced
9710:5d306df084eb 9711:0f2fe7d37d8c
610 // open the directory and check if the file for the given vmid exists. 610 // open the directory and check if the file for the given vmid exists.
611 // The file with the expected name and the latest creation date is used 611 // The file with the expected name and the latest creation date is used
612 // to determine the user name for the process id. 612 // to determine the user name for the process id.
613 // 613 //
614 struct dirent* dentry; 614 struct dirent* dentry;
615 char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);
616 errno = 0; 615 errno = 0;
617 while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) { 616 while ((dentry = os::readdir(tmpdirp)) != NULL) {
618 617
619 // check if the directory entry is a hsperfdata file 618 // check if the directory entry is a hsperfdata file
620 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { 619 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
621 continue; 620 continue;
622 } 621 }
646 os::closedir(subdirp); 645 os::closedir(subdirp);
647 continue; 646 continue;
648 } 647 }
649 648
650 struct dirent* udentry; 649 struct dirent* udentry;
651 char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
652 errno = 0; 650 errno = 0;
653 while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) { 651 while ((udentry = os::readdir(subdirp)) != NULL) {
654 652
655 if (filename_to_pid(udentry->d_name) == vmid) { 653 if (filename_to_pid(udentry->d_name) == vmid) {
656 struct stat statbuf; 654 struct stat statbuf;
657 int result; 655 int result;
658 656
692 690
693 FREE_C_HEAP_ARRAY(char, filename, mtInternal); 691 FREE_C_HEAP_ARRAY(char, filename, mtInternal);
694 } 692 }
695 } 693 }
696 os::closedir(subdirp); 694 os::closedir(subdirp);
697 FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
698 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal); 695 FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
699 } 696 }
700 os::closedir(tmpdirp); 697 os::closedir(tmpdirp);
701 FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
702 698
703 return(oldest_user); 699 return(oldest_user);
704 } 700 }
705 701
706 // return the name of the user that owns the JVM indicated by the given vmid. 702 // return the name of the user that owns the JVM indicated by the given vmid.
772 // for this user may start and/or terminate during this search and 768 // for this user may start and/or terminate during this search and
773 // remove or create new files in this directory. The behavior of this 769 // remove or create new files in this directory. The behavior of this
774 // loop under these conditions is dependent upon the implementation of 770 // loop under these conditions is dependent upon the implementation of
775 // opendir/readdir. 771 // opendir/readdir.
776 struct dirent* entry; 772 struct dirent* entry;
777 char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
778
779 errno = 0; 773 errno = 0;
780 while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) { 774 while ((entry = os::readdir(dirp)) != NULL) {
781 775
782 pid_t pid = filename_to_pid(entry->d_name); 776 pid_t pid = filename_to_pid(entry->d_name);
783 777
784 if (pid == 0) { 778 if (pid == 0) {
785 779
814 } 808 }
815 809
816 // Close the directory and reset the current working directory. 810 // Close the directory and reset the current working directory.
817 close_directory_secure_cwd(dirp, saved_cwd_fd); 811 close_directory_secure_cwd(dirp, saved_cwd_fd);
818 812
819 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
820 } 813 }
821 814
822 // Make the user specific temporary directory. Returns true if 815 // Make the user specific temporary directory. Returns true if
823 // the directory exists and is secure upon return. Returns false 816 // the directory exists and is secure upon return. Returns false
824 // if the directory exists but is either a symlink, is otherwise 817 // if the directory exists but is either a symlink, is otherwise

mercurial