8199811: com/sun/jdi/ProcessAttachTest.java fails intermittently: Remote thread failed for unknown reason
authorcjplummer
Wed, 29 Aug 2018 20:13:53 -0700
changeset 51584 d395677d99f3
parent 51583 ad2224d4f346
child 51585 c25f6c562bf5
8199811: com/sun/jdi/ProcessAttachTest.java fails intermittently: Remote thread failed for unknown reason Summary: give attach listener thread a chance to finish starting Reviewed-by: dholmes, gadams
src/hotspot/os/solaris/attachListener_solaris.cpp
src/hotspot/os/windows/attachListener_windows.cpp
--- a/src/hotspot/os/solaris/attachListener_solaris.cpp	Tue Aug 28 08:06:59 2018 -0400
+++ b/src/hotspot/os/solaris/attachListener_solaris.cpp	Wed Aug 29 20:13:53 2018 -0700
@@ -294,12 +294,17 @@
     int return_fd = -1;
     SolarisAttachOperation* op = NULL;
 
-    // no listener
+    // wait up to 10 seconds for listener to be up and running
     jint res = 0;
-    if (!AttachListener::is_initialized()) {
-      // how did we get here?
-      debug_only(warning("door_call when not enabled"));
-      res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
+    int sleep_count = 0;
+    while (!AttachListener::is_initialized()) {
+      sleep(1); // 1 second
+      sleep_count++;
+      if (sleep_count > 10) { // try for 10 seconds
+        debug_only(warning("door_call when not enabled"));
+        res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
+        break;
+      }
     }
 
     // check client credentials
--- a/src/hotspot/os/windows/attachListener_windows.cpp	Tue Aug 28 08:06:59 2018 -0400
+++ b/src/hotspot/os/windows/attachListener_windows.cpp	Wed Aug 29 20:13:53 2018 -0700
@@ -184,9 +184,14 @@
 // Also we need to be careful not to execute anything that results in more than a 4k stack.
 //
 int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) {
-  // listener not running
-  if (!AttachListener::is_initialized()) {
-    return ATTACH_ERROR_DISABLED;
+  // wait up to 10 seconds for listener to be up and running
+  int sleep_count = 0;
+  while (!AttachListener::is_initialized()) {
+    Sleep(1000); // 1 second
+    sleep_count++;
+    if (sleep_count > 10) { // try for 10 seconds
+      return ATTACH_ERROR_DISABLED;
+    }
   }
 
   // check that all paramteres to the operation