changeset 5832:6945749afd34

Merge
author asaha
date Fri, 09 Jan 2015 13:42:40 -0800
parents effb7f4183cf ef111e319636
children b159db64fca1
files .hgtags make/hotspot_version src/share/vm/runtime/arguments.cpp
diffstat 3 files changed, 91 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Jan 07 12:28:19 2015 -0800
+++ b/.hgtags	Fri Jan 09 13:42:40 2015 -0800
@@ -752,6 +752,10 @@
 d9b56c6bdddb6f9d8242230f5fdd58f9c7d30ea5 jdk7u72-b14
 a6ae698522bfab3c595a4f8c2c3ee7e8939eb1bb jdk7u72-b30
 492a2abed4ca015459e24f7348233531b7e929d2 jdk7u72-b31
+61dacdb82145abe6cb5911e5a06fd8d8622fb55f jdk7u72-b32
+64cbcac4027843d0292f262520a8945161cc1657 jdk7u72-b33
+bcb9613e07e212f3103a3bcc5e5085b4d69ad5e1 jdk7u72-b34
+f9c89a617dac063054749d1880807f6700f04c8a jdk7u72-b35
 e6b6d91b3934c281086f8efacb0926e7451cc18b jdk7u75-b00
 9096ac248b379a0f3012f18c7289ec47cdef8459 jdk7u75-b01
 a6964b2822d906eab9c923cdd723cf3dd4facfcd jdk7u75-b02
@@ -784,6 +788,9 @@
 a395c29532e5322657c542d54dd957940cf2f523 jdk7u76-b13
 98f0c5279ba76eb1b5741dc67f7b5f10e7508449 jdk7u76-b30
 875d0ccc97fe7a46a0a9996e897827022db58200 jdk7u76-b31
+2480d9d778301a3f88b0ab8ee35a585df82528e5 jdk7u79-b00
+ae6723b35de91e3e964cc92d832e17743e4f43c6 jdk7u79-b01
+653c92d16c45392cd7a5073528c8b8396c1f087c jdk7u79-b02
 b92f390febd01615af4a736b4f830f6052aa1d09 hs24.80-b00
 1448ebfef4f1aae0174eca983ad05507730ca6fd hs24.80-b01
 b1d29549dca7e36a4d050af5a54f8f56963a5c7d hs24.80-b02
--- a/src/share/vm/runtime/arguments.cpp	Wed Jan 07 12:28:19 2015 -0800
+++ b/src/share/vm/runtime/arguments.cpp	Fri Jan 09 13:42:40 2015 -0800
@@ -2065,7 +2065,7 @@
                                         "G1ConcMarkStepDurationMillis");
     status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte,
                                        "G1ConcRSHotCardLimit");
-    status = status && verify_interval(G1ConcRSLogCacheSize, 0, 31,
+    status = status && verify_interval(G1ConcRSLogCacheSize, 0, 27,
                                        "G1ConcRSLogCacheSize");
   }
 #endif
--- a/src/share/vm/utilities/ostream.cpp	Wed Jan 07 12:28:19 2015 -0800
+++ b/src/share/vm/utilities/ostream.cpp	Fri Jan 09 13:42:40 2015 -0800
@@ -356,7 +356,6 @@
 
 #define EXTRACHARLEN   32
 #define CURRENTAPPX    ".current"
-#define FILENAMEBUFLEN  1024
 // convert YYYY-MM-DD HH:MM:SS to YYYY-MM-DD_HH-MM-SS
 char* get_datetime_string(char *buf, size_t len) {
   os::local_time_string(buf, len);
@@ -390,7 +389,6 @@
     buffer_length = strlen(log_name) + 1;
   }
 
-  // const char* star = strchr(basename, '*');
   const char* pts = strstr(basename, "%p");
   int pid_pos = (pts == NULL) ? -1 : (pts - nametail);
 
@@ -583,9 +581,16 @@
   _bytes_written = 0L;
   _file_name = make_log_name(file_name, NULL);
 
+  if (_file_name == NULL) {
+    warning("Cannot open file %s: file name is too long.\n", file_name);
+    _need_close = false;
+    UseGCLogFileRotation = false;
+    return;
+  }
+
   // gc log file rotation
   if (UseGCLogFileRotation && NumberOfGCLogFiles > 1) {
-    char tempbuf[FILENAMEBUFLEN];
+    char tempbuf[JVM_MAXPATHLEN];
     jio_snprintf(tempbuf, sizeof(tempbuf), "%s.%d" CURRENTAPPX, _file_name, _cur_file_num);
     _file = fopen(tempbuf, "w");
   } else {
@@ -617,10 +622,10 @@
 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
 // must be synchronized.
 void gcLogFileStream::rotate_log(bool force, outputStream* out) {
-  char time_msg[FILENAMEBUFLEN];
+  char time_msg[O_BUFLEN];
   char time_str[EXTRACHARLEN];
-  char current_file_name[FILENAMEBUFLEN];
-  char renamed_file_name[FILENAMEBUFLEN];
+  char current_file_name[JVM_MAXPATHLEN];
+  char renamed_file_name[JVM_MAXPATHLEN];
 
   if (!should_rotate(force)) {
     return;
@@ -659,12 +664,15 @@
   // have a form of extended_filename.<i>.current where i is the current rotation
   // file number. After it reaches max file size, the file will be saved and renamed
   // with .current removed from its tail.
-  size_t filename_len = strlen(_file_name);
   if (_file != NULL) {
-    jio_snprintf(renamed_file_name, filename_len + EXTRACHARLEN, "%s.%d",
+    jio_snprintf(renamed_file_name, JVM_MAXPATHLEN, "%s.%d",
                  _file_name, _cur_file_num);
-    jio_snprintf(current_file_name, filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX,
-                 _file_name, _cur_file_num);
+    int result = jio_snprintf(current_file_name, JVM_MAXPATHLEN,
+                              "%s.%d" CURRENTAPPX, _file_name, _cur_file_num);
+    if (result >= JVM_MAXPATHLEN) {
+      warning("Cannot create new log file name: %s: file name is too long.\n", current_file_name);
+      return;
+    }
 
     const char* msg = force ? "GC log rotation request has been received."
                             : "GC log file has reached the maximum size.";
@@ -703,19 +711,23 @@
 
   _cur_file_num++;
   if (_cur_file_num > NumberOfGCLogFiles - 1) _cur_file_num = 0;
-  jio_snprintf(current_file_name,  filename_len + EXTRACHARLEN, "%s.%d" CURRENTAPPX,
+  int result = jio_snprintf(current_file_name,  JVM_MAXPATHLEN, "%s.%d" CURRENTAPPX,
                _file_name, _cur_file_num);
+  if (result >= JVM_MAXPATHLEN) {
+    warning("Cannot create new log file name: %s: file name is too long.\n", current_file_name);
+    return;
+  }
+
   _file = fopen(current_file_name, "w");
 
   if (_file != NULL) {
     _bytes_written = 0L;
     _need_close = true;
     // reuse current_file_name for time_msg
-    jio_snprintf(current_file_name, filename_len + EXTRACHARLEN,
+    jio_snprintf(current_file_name, JVM_MAXPATHLEN,
                  "%s.%d", _file_name, _cur_file_num);
     jio_snprintf(time_msg, sizeof(time_msg), "%s GC log file created %s\n",
-                           os::local_time_string((char *)time_str, sizeof(time_str)),
-                           current_file_name);
+                 os::local_time_string((char *)time_str, sizeof(time_str)), current_file_name);
     write(time_msg, strlen(time_msg));
 
     if (out != NULL) {
@@ -804,7 +816,7 @@
 
 void defaultStream::init_log() {
   // %%% Need a MutexLocker?
-  const char* log_name = LogFile != NULL ? LogFile : "hotspot.log";
+  const char* log_name = LogFile != NULL ? LogFile : "hotspot_%p.log";
   fileStream* file = open_file(log_name);
 
   if (file != NULL) {
@@ -1236,14 +1248,55 @@
 
 #ifndef PRODUCT
 void test_loggc_filename() {
+  int pid;
+  char  tms[32];
+  char  i_result[JVM_MAXPATHLEN];
   const char* o_result;
+  get_datetime_string(tms, sizeof(tms));
+  pid = os::current_process_id();
+
+  // test.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "test.log", tms);
+  o_result = make_log_name_internal("test.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
+
+  // test-%t-%p.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "test-%s-pid%u.log", tms, pid);
+  o_result = make_log_name_internal("test-%t-%p.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test-%%t-%%p.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
+
+  // test-%t%p.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "test-%spid%u.log", tms, pid);
+  o_result = make_log_name_internal("test-%t%p.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"test-%%t%%p.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
+
+  // %p%t.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "pid%u%s.log", pid, tms);
+  o_result = make_log_name_internal("%p%t.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p%%t.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
+
+  // %p-test.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "pid%u-test.log", pid);
+  o_result = make_log_name_internal("%p-test.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%p-test.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
+
+  // %t.log
+  jio_snprintf(i_result, JVM_MAXPATHLEN, "%s.log", tms);
+  o_result = make_log_name_internal("%t.log", NULL, pid, tms);
+  assert(strcmp(i_result, o_result) == 0, "failed on testing make_log_name(\"%%t.log\", NULL)");
+  FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
 
   {
     // longest filename
     char longest_name[JVM_MAXPATHLEN];
     memset(longest_name, 'a', sizeof(longest_name));
     longest_name[JVM_MAXPATHLEN - 1] = '\0';
-    o_result = make_log_name((const char*)&longest_name, NULL);
+    o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
     assert(strcmp(longest_name, o_result) == 0, err_msg("longest name does not match. expected '%s' but got '%s'", longest_name, o_result));
     FREE_C_HEAP_ARRAY(char, o_result, mtInternal);
   }
@@ -1254,29 +1307,30 @@
     int too_long_length = sizeof(too_long_name);
     memset(too_long_name, 'a', too_long_length);
     too_long_name[too_long_length - 1] = '\0';
-    o_result = make_log_name((const char*)&too_long_name, NULL);
+    o_result = make_log_name_internal((const char*)&too_long_name, NULL, pid, tms);
     assert(o_result == NULL, err_msg("Too long file name should return NULL, but got '%s'", o_result));
   }
 
   {
+    // too long with timestamp
+    char longest_name[JVM_MAXPATHLEN];
+    memset(longest_name, 'a', JVM_MAXPATHLEN);
+    longest_name[JVM_MAXPATHLEN - 3] = '%';
+    longest_name[JVM_MAXPATHLEN - 2] = 't';
+    longest_name[JVM_MAXPATHLEN - 1] = '\0';
+    o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
+    assert(o_result == NULL, err_msg("Too long file name after timestamp expansion should return NULL, but got '%s'", o_result));
+  }
+
+  {
     // too long with pid
     char longest_name[JVM_MAXPATHLEN];
     memset(longest_name, 'a', JVM_MAXPATHLEN);
     longest_name[JVM_MAXPATHLEN - 3] = '%';
     longest_name[JVM_MAXPATHLEN - 2] = 'p';
     longest_name[JVM_MAXPATHLEN - 1] = '\0';
-    o_result = make_log_name((const char*)&longest_name, NULL);
-    assert(o_result == NULL, err_msg("Too long file name after %%p pid expansion should return NULL, but got '%s'", o_result));
-  }
-
-  {
-    // too long with pid (star)
-    char longest_name[JVM_MAXPATHLEN];
-    memset(longest_name, 'a', JVM_MAXPATHLEN);
-    longest_name[JVM_MAXPATHLEN - 2] = '*';
-    longest_name[JVM_MAXPATHLEN - 1] = '\0';
-    o_result = make_log_name((const char*)&longest_name, NULL);
-    assert(o_result == NULL, err_msg("Too long file name after star (pid) expansion should return NULL, but got '%s'", o_result));
+    o_result = make_log_name_internal((const char*)&longest_name, NULL, pid, tms);
+    assert(o_result == NULL, err_msg("Too long file name after pid expansion should return NULL, but got '%s'", o_result));
   }
 }