8166012: [linux] Remove remnants of LinuxThreads from Linux attach framework
Reviewed-by: dholmes, alanb
This commit is contained in:
parent
08d5007708
commit
18b01dde66
@ -30,8 +30,6 @@ SUNWprivate_1.1 {
|
||||
Java_sun_tools_attach_VirtualMachineImpl_checkPermissions;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_close;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_connect;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_open;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo;
|
||||
Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf;
|
||||
|
@ -308,10 +308,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
|
||||
//-- native methods
|
||||
|
||||
static native boolean isLinuxThreads();
|
||||
|
||||
static native int getLinuxThreadsManager(int pid) throws IOException;
|
||||
|
||||
static native void sendQuitToChildrenOf(int pid) throws IOException;
|
||||
|
||||
static native void sendQuitTo(int pid) throws IOException;
|
||||
|
@ -194,113 +194,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_connect
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_tools_attach_VirtualMachineImpl
|
||||
* Method: isLinuxThreads
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
# ifndef _CS_GNU_LIBPTHREAD_VERSION
|
||||
# define _CS_GNU_LIBPTHREAD_VERSION 3
|
||||
# endif
|
||||
size_t n;
|
||||
char* s;
|
||||
jboolean res;
|
||||
|
||||
n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
|
||||
if (n <= 0) {
|
||||
/* glibc before 2.3.2 only has LinuxThreads */
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
s = (char *)malloc(n);
|
||||
if (s == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, "malloc failed");
|
||||
return JNI_TRUE;
|
||||
}
|
||||
confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
|
||||
|
||||
/*
|
||||
* If the LIBPTHREAD version include "NPTL" then we know we
|
||||
* have the new threads library and not LinuxThreads
|
||||
*/
|
||||
res = (jboolean)(strstr(s, "NPTL") == NULL);
|
||||
free(s);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure and callback function used to count the children of
|
||||
* a given process, and record the pid of the "manager thread".
|
||||
*/
|
||||
typedef struct {
|
||||
pid_t ppid;
|
||||
int count;
|
||||
pid_t mpid;
|
||||
} ChildCountContext;
|
||||
|
||||
static void ChildCountCallback(const pid_t pid, void* user_data) {
|
||||
ChildCountContext* context = (ChildCountContext*)user_data;
|
||||
if (getParent(pid) == context->ppid) {
|
||||
context->count++;
|
||||
/*
|
||||
* Remember the pid of the first child. If the final count is
|
||||
* one then this is the pid of the LinuxThreads manager.
|
||||
*/
|
||||
if (context->count == 1) {
|
||||
context->mpid = pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_tools_attach_VirtualMachineImpl
|
||||
* Method: getLinuxThreadsManager
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager
|
||||
(JNIEnv *env, jclass cls, jint pid)
|
||||
{
|
||||
ChildCountContext context;
|
||||
|
||||
/*
|
||||
* Iterate over all processes to find how many children 'pid' has
|
||||
*/
|
||||
context.ppid = pid;
|
||||
context.count = 0;
|
||||
context.mpid = (pid_t)0;
|
||||
forEachProcess(ChildCountCallback, (void*)&context);
|
||||
|
||||
/*
|
||||
* If there's no children then this is likely the pid of the primordial
|
||||
* created by the launcher - in that case the LinuxThreads manager is the
|
||||
* parent of this process.
|
||||
*/
|
||||
if (context.count == 0) {
|
||||
pid_t parent = getParent(pid);
|
||||
if ((int)parent > 0) {
|
||||
return (jint)parent;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* There's one child so this is likely the embedded VM case where the
|
||||
* the primordial thread == LinuxThreads initial thread. The LinuxThreads
|
||||
* manager in that case is the child.
|
||||
*/
|
||||
if (context.count == 1) {
|
||||
return (jint)context.mpid;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here it's most likely we were given the wrong pid
|
||||
*/
|
||||
JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Structure and callback function used to send a QUIT signal to all
|
||||
* children of a given process
|
||||
|
Loading…
Reference in New Issue
Block a user