8150232: AIX cleanup: Integrate changes of 7178026 and others
authorclanger
Fri, 19 Feb 2016 10:44:54 +0100
changeset 36197 40b356f0cdf5
parent 36196 5128f617b0c6
child 36198 658f3871f6a2
child 36199 855b44ce93c0
8150232: AIX cleanup: Integrate changes of 7178026 and others Reviewed-by: simonis
hotspot/src/os/aix/vm/attachListener_aix.cpp
hotspot/src/os/aix/vm/perfMemory_aix.cpp
--- a/hotspot/src/os/aix/vm/attachListener_aix.cpp	Fri Feb 19 15:14:59 2016 -0500
+++ b/hotspot/src/os/aix/vm/attachListener_aix.cpp	Fri Feb 19 10:44:54 2016 +0100
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -225,7 +225,7 @@
   // We must call bind with the actual socketaddr length. This is obligatory for AS400.
   int res = ::bind(listener, (struct sockaddr*)&addr, SUN_LEN(&addr));
   if (res == -1) {
-    RESTARTABLE(::close(listener), res);
+    ::close(listener);
     return -1;
   }
 
@@ -238,7 +238,7 @@
       }
   }
   if (res == -1) {
-    RESTARTABLE(::close(listener), res);
+    ::close(listener);
     ::unlink(initial_path);
     return -1;
   }
@@ -400,7 +400,7 @@
     AixAttachOperation* op = read_request(s);
     if (op == NULL) {
       int res;
-      RESTARTABLE(::close(s), res);
+      ::close(s);
       continue;
     } else {
       return op;
@@ -452,7 +452,7 @@
   }
 
   // done
-  RESTARTABLE(::close(this->socket()), rc);
+  ::close(this->socket());
 
   // were we externally suspended while we were waiting?
   thread->check_and_wait_while_suspended();
--- a/hotspot/src/os/aix/vm/perfMemory_aix.cpp	Fri Feb 19 15:14:59 2016 -0500
+++ b/hotspot/src/os/aix/vm/perfMemory_aix.cpp	Fri Feb 19 10:44:54 2016 +0100
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2013 SAP SE. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -121,7 +121,7 @@
       addr += result;
     }
 
-    RESTARTABLE(::close(fd), result);
+    result = ::close(fd);
     if (PrintMiscellaneous && Verbose) {
       if (result == OS_ERR) {
         warning("Could not close %s: %s\n", destfile, strerror(errno));
@@ -299,10 +299,13 @@
   bool create;
   int error;
   int fd;
+  int result;
 
   create = false;
 
-  if (lstat(path, &orig_st) != 0) {
+  RESTARTABLE(::lstat(path, &orig_st), result);
+
+  if (result == OS_ERR) {
     if (errno == ENOENT && (oflag & O_CREAT) != 0) {
       // File doesn't exist, but_we want to create it, add O_EXCL flag
       // to make sure no-one creates it (or a symlink) before us
@@ -316,7 +319,7 @@
       return OS_ERR;
     }
   } else {
-    // Lstat success, check if existing file is a link.
+    // lstat success, check if existing file is a link.
     if ((orig_st.st_mode & S_IFMT) == S_IFLNK)  {
       // File is a symlink.
       errno = ELOOP;
@@ -325,9 +328,9 @@
   }
 
   if (use_mode == true) {
-    fd = open(path, oflag, mode);
+    RESTARTABLE(::open(path, oflag, mode), fd);
   } else {
-    fd = open(path, oflag);
+    RESTARTABLE(::open(path, oflag), fd);
   }
 
   if (fd == OS_ERR) {
@@ -336,7 +339,8 @@
 
   // Can't do inode checks on before/after if we created the file.
   if (create == false) {
-    if (fstat(fd, &new_st) != 0) {
+    RESTARTABLE(::fstat(fd, &new_st), result);
+    if (result == OS_ERR) {
       // Keep errno from fstat, in case close also fails.
       error = errno;
       ::close(fd);
@@ -384,7 +388,7 @@
   RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
 #else
   // workaround (jdk6 coding)
-  RESTARTABLE(::open_o_nofollow(dirname, O_RDONLY), result);
+  result = open_o_nofollow(dirname, O_RDONLY);
 #endif
 
   if (result == OS_ERR) {
@@ -888,7 +892,7 @@
   RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
 #else
   // workaround function (jdk6 code)
-  RESTARTABLE(::open_o_nofollow(filename, O_RDWR|O_CREAT, S_IREAD|S_IWRITE), result);
+  result = open_o_nofollow(filename, O_RDWR|O_CREAT, S_IREAD|S_IWRITE);
 #endif
 
   if (result == OS_ERR) {
@@ -931,7 +935,7 @@
     if (PrintMiscellaneous && Verbose) {
       warning("could not set shared memory file size: %s\n", strerror(errno));
     }
-    RESTARTABLE(::close(fd), result);
+    ::close(fd);
     return -1;
   }
 
@@ -951,7 +955,7 @@
 #ifdef O_NOFOLLOW
   RESTARTABLE(::open(filename, oflags), result);
 #else
-  RESTARTABLE(::open_o_nofollow(filename, oflags), result);
+  open_o_nofollow(filename, oflags);
 #endif
 
   if (result == OS_ERR) {
@@ -1006,8 +1010,7 @@
 
   char* dirname = get_user_tmp_dir(user_name);
   char* filename = get_sharedmem_filename(dirname, vmid);
-
-  // Get the short filename.
+  // get the short filename.
   char* short_filename = strrchr(filename, '/');
   if (short_filename == NULL) {
     short_filename = filename;
@@ -1033,9 +1036,7 @@
 
   mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
 
-  // attempt to close the file - restart it if it was interrupted,
-  // but ignore other failures
-  RESTARTABLE(::close(fd), result);
+  result = ::close(fd);
   assert(result != OS_ERR, "could not close file");
 
   if (mapAddress == MAP_FAILED) {
@@ -1142,7 +1143,6 @@
   // constructs for the file and the shared memory mapping.
   if (mode == PerfMemory::PERF_MODE_RO) {
     mmap_prot = PROT_READ;
-
   // No O_NOFOLLOW defined at buildtime, and it is not documented for open.
 #ifdef O_NOFOLLOW
     file_flags = O_RDONLY | O_NOFOLLOW;
@@ -1205,21 +1205,28 @@
   FREE_C_HEAP_ARRAY(char, filename);
 
   // open the shared memory file for the give vmid
-  fd = open_sharedmem_file(rfilename, file_flags, CHECK);
-  assert(fd != OS_ERR, "unexpected value");
+  fd = open_sharedmem_file(rfilename, file_flags, THREAD);
+
+  if (fd == OS_ERR) {
+    return;
+  }
+
+  if (HAS_PENDING_EXCEPTION) {
+    ::close(fd);
+    return;
+  }
 
   if (*sizep == 0) {
     size = sharedmem_filesize(fd, CHECK);
-    assert(size != 0, "unexpected size");
   } else {
     size = *sizep;
   }
 
+  assert(size > 0, "unexpected size <= 0");
+
   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
 
-  // attempt to close the file - restart if it gets interrupted,
-  // but ignore other failures
-  RESTARTABLE(::close(fd), result);
+  result = ::close(fd);
   assert(result != OS_ERR, "could not close file");
 
   if (mapAddress == MAP_FAILED) {
@@ -1230,7 +1237,7 @@
               "Could not map PerfMemory");
   }
 
-  // It does not go through os api, the operation has to record from here.
+  // it does not go through os api, the operation has to record from here.
   MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC, mtInternal);
 
   *addr = mapAddress;
@@ -1238,7 +1245,7 @@
 
   if (PerfTraceMemOps) {
     tty->print("mapped " SIZE_FORMAT " bytes for vmid %d at "
-               INTPTR_FORMAT "\n", size, vmid, (void*)mapAddress);
+               INTPTR_FORMAT "\n", size, vmid, p2i((void*)mapAddress));
   }
 }