< prev index next >

src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java

Print this page

        

*** 42,54 **** // location is the same for all processes, otherwise the tools // will not be able to find all Hotspot processes. // Any changes to this needs to be synchronized with HotSpot. private static final String tmpdir = "/tmp"; - // Indicates if this machine uses the old LinuxThreads - static boolean isLinuxThreads; - // The patch to the socket file created by the target VM String path; /** * Attaches to the target VM --- 42,51 ----
*** 71,113 **** // Then we attempt to find the socket file again. path = findSocketFile(pid); if (path == null) { File f = createAttachFile(pid); try { - // On LinuxThreads each thread is a process and we don't have the - // pid of the VMThread which has SIGQUIT unblocked. To workaround - // this we get the pid of the "manager thread" that is created - // by the first call to pthread_create. This is parent of all - // threads (except the initial thread). - if (isLinuxThreads) { - int mpid; - try { - mpid = getLinuxThreadsManager(pid); - } catch (IOException x) { - throw new AttachNotSupportedException(x.getMessage()); - } - assert(mpid >= 1); - sendQuitToChildrenOf(mpid); - } else { sendQuitTo(pid); - } // give the target VM time to start the attach mechanism ! int i = 0; ! long delay = 200; ! int retries = (int)(attachTimeout() / delay); do { try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); ! i++; ! } while (i <= retries && path == null); if (path == null) { throw new AttachNotSupportedException( ! "Unable to open socket file: target process not responding " + ! "or HotSpot VM not loaded"); } } finally { f.delete(); } } --- 68,101 ---- // Then we attempt to find the socket file again. path = findSocketFile(pid); if (path == null) { File f = createAttachFile(pid); try { sendQuitTo(pid); // give the target VM time to start the attach mechanism ! final int delay_step = 100; ! final long timeout = attachTimeout(); ! long time_spend = 0; ! long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); ! ! time_spend += delay; ! if (time_spend > timeout/2 && path == null) { ! // Send QUIT again to give target VM the last chance to react ! sendQuitTo(pid); ! } ! } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( ! String.format("Unable to open socket file: target process %d not responding within %dms or HotSpot VM not loaded", pid, time_spend)); } } finally { f.delete(); } }
*** 338,345 **** static native void write(int fd, byte buf[], int off, int bufLen) throws IOException; static { System.loadLibrary("attach"); - isLinuxThreads = isLinuxThreads(); } } --- 326,332 ----
< prev index next >