< prev index next >

src/hotspot/os/linux/perfMemory_linux.cpp

Print this page
rev 50985 : 8206977: Minor improvements of runtime code.
Reviewed-by: coleenp, lfoltan


 517 //
 518 // If nspid != -1, look in /proc/{vmid}/root/tmp for directories
 519 // containing nspid, otherwise just look for vmid in /tmp
 520 //
 521 static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
 522 
 523   // short circuit the directory search if the process doesn't even exist.
 524   if (kill(vmid, 0) == OS_ERR) {
 525     if (errno == ESRCH) {
 526       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 527                   "Process not found");
 528     }
 529     else /* EPERM */ {
 530       THROW_MSG_0(vmSymbols::java_io_IOException(), os::strerror(errno));
 531     }
 532   }
 533 
 534   // directory search
 535   char* oldest_user = NULL;
 536   time_t oldest_ctime = 0;
 537   char buffer[TMP_BUFFER_LEN];
 538   int searchpid;
 539   char* tmpdirname = (char *)os::get_temp_directory();
 540   assert(strlen(tmpdirname) == 4, "No longer using /tmp - update buffer size");
 541 
 542   if (nspid == -1) {
 543     searchpid = vmid;
 544   }
 545   else {
 546     jio_snprintf(buffer, MAXPATHLEN, "/proc/%d/root%s", vmid, tmpdirname);
 547     tmpdirname = buffer;
 548     searchpid = nspid;
 549   }
 550 
 551   // open the temp directory
 552   DIR* tmpdirp = os::opendir(tmpdirname);
 553 
 554   if (tmpdirp == NULL) {
 555     // Cannot open the directory to get the user name, return.
 556     return NULL;
 557   }
 558 
 559   // for each entry in the directory that matches the pattern hsperfdata_*,
 560   // open the directory and check if the file for the given vmid or nspid exists.
 561   // The file with the expected name and the latest creation date is used
 562   // to determine the user name for the process id.
 563   //
 564   struct dirent* dentry;
 565   char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);




 517 //
 518 // If nspid != -1, look in /proc/{vmid}/root/tmp for directories
 519 // containing nspid, otherwise just look for vmid in /tmp
 520 //
 521 static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
 522 
 523   // short circuit the directory search if the process doesn't even exist.
 524   if (kill(vmid, 0) == OS_ERR) {
 525     if (errno == ESRCH) {
 526       THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
 527                   "Process not found");
 528     }
 529     else /* EPERM */ {
 530       THROW_MSG_0(vmSymbols::java_io_IOException(), os::strerror(errno));
 531     }
 532   }
 533 
 534   // directory search
 535   char* oldest_user = NULL;
 536   time_t oldest_ctime = 0;
 537   char buffer[MAXPATHLEN + 1];
 538   int searchpid;
 539   char* tmpdirname = (char *)os::get_temp_directory();
 540   assert(strlen(tmpdirname) == 4, "No longer using /tmp - update buffer size");
 541 
 542   if (nspid == -1) {
 543     searchpid = vmid;
 544   } else {

 545     jio_snprintf(buffer, MAXPATHLEN, "/proc/%d/root%s", vmid, tmpdirname);
 546     tmpdirname = buffer;
 547     searchpid = nspid;
 548   }
 549 
 550   // open the temp directory
 551   DIR* tmpdirp = os::opendir(tmpdirname);
 552 
 553   if (tmpdirp == NULL) {
 554     // Cannot open the directory to get the user name, return.
 555     return NULL;
 556   }
 557 
 558   // for each entry in the directory that matches the pattern hsperfdata_*,
 559   // open the directory and check if the file for the given vmid or nspid exists.
 560   // The file with the expected name and the latest creation date is used
 561   // to determine the user name for the process id.
 562   //
 563   struct dirent* dentry;
 564   char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname), mtInternal);


< prev index next >