8199811: com/sun/jdi/ProcessAttachTest.java fails intermittently: Remote thread failed for unknown reason

Give attach listener thread a chance to finish starting

Reviewed-by: dholmes, gadams
This commit is contained in:
Chris Plummer 2018-08-29 20:13:53 -07:00
parent b984ecc438
commit 77921f8a38
2 changed files with 18 additions and 8 deletions

@ -294,12 +294,17 @@ extern "C" {
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

@ -184,9 +184,14 @@ int Win32AttachListener::init() {
// 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