comparison src/os/solaris/vm/perfMemory_solaris.cpp @ 9064:4b7cf00ccb08

8006001: [parfait] Possible file leak in hotspot/src/os/linux/vm/perfMemory_linux.cpp Reviewed-by: zgu, coleenp, hseigel, dholmes
author ccheung
date Fri, 05 Apr 2013 11:15:13 -0700
parents 716c64bda5ba
children a837fa3d3f86
comparison
equal deleted inserted replaced
9060:cc32ccaaf47f 9064:4b7cf00ccb08
685 // open the file 685 // open the file
686 int result; 686 int result;
687 RESTARTABLE(::open(filename, oflags), result); 687 RESTARTABLE(::open(filename, oflags), result);
688 if (result == OS_ERR) { 688 if (result == OS_ERR) {
689 if (errno == ENOENT) { 689 if (errno == ENOENT) {
690 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 690 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
691 "Process not found"); 691 "Process not found", OS_ERR);
692 } 692 }
693 else if (errno == EACCES) { 693 else if (errno == EACCES) {
694 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 694 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
695 "Permission denied"); 695 "Permission denied", OS_ERR);
696 } 696 }
697 else { 697 else {
698 THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno)); 698 THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
699 } 699 }
700 } 700 }
701 701
702 return result; 702 return result;
703 } 703 }
841 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) { 841 static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
842 842
843 char* mapAddress; 843 char* mapAddress;
844 int result; 844 int result;
845 int fd; 845 int fd;
846 size_t size; 846 size_t size = 0;
847 const char* luser = NULL; 847 const char* luser = NULL;
848 848
849 int mmap_prot; 849 int mmap_prot;
850 int file_flags; 850 int file_flags;
851 851
912 fd = open_sharedmem_file(rfilename, file_flags, CHECK); 912 fd = open_sharedmem_file(rfilename, file_flags, CHECK);
913 assert(fd != OS_ERR, "unexpected value"); 913 assert(fd != OS_ERR, "unexpected value");
914 914
915 if (*sizep == 0) { 915 if (*sizep == 0) {
916 size = sharedmem_filesize(fd, CHECK); 916 size = sharedmem_filesize(fd, CHECK);
917 assert(size != 0, "unexpected size"); 917 } else {
918 } 918 size = *sizep;
919 }
920
921 assert(size > 0, "unexpected size <= 0");
919 922
920 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); 923 mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
921 924
922 // attempt to close the file - restart if it gets interrupted, 925 // attempt to close the file - restart if it gets interrupted,
923 // but ignore other failures 926 // but ignore other failures