< prev index next >
src/share/vm/services/attachListener.hpp
Print this page
rev 9381 : 8225690: Multiple AttachListener threads can be created
Reviewed-by: sspitsyn, cjplummer
*** 24,33 ****
--- 24,34 ----
#ifndef SHARE_VM_SERVICES_ATTACHLISTENER_HPP
#define SHARE_VM_SERVICES_ATTACHLISTENER_HPP
#include "memory/allocation.hpp"
+ #include "runtime/atomic.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
#include "utilities/macros.hpp"
// The AttachListener thread services a queue of operations that are enqueued
*** 46,79 ****
struct AttachOperationFunctionInfo {
const char* name;
AttachOperationFunction func;
};
class AttachListener: AllStatic {
public:
static void vm_start() NOT_SERVICES_RETURN;
static void init() NOT_SERVICES_RETURN;
static void abort() NOT_SERVICES_RETURN;
// invoke to perform clean-up tasks when all clients detach
static void detachall() NOT_SERVICES_RETURN;
// indicates if the Attach Listener needs to be created at startup
static bool init_at_startup() NOT_SERVICES_RETURN_(false);
// indicates if we have a trigger to start the Attach Listener
static bool is_init_trigger() NOT_SERVICES_RETURN_(false);
#if !INCLUDE_SERVICES
static bool is_attach_supported() { return false; }
#else
private:
! static volatile bool _initialized;
public:
! static bool is_initialized() { return _initialized; }
! static void set_initialized() { _initialized = true; }
// indicates if this VM supports attach-on-demand
static bool is_attach_supported() { return !DisableAttachMechanism; }
// platform specific initialization
--- 47,108 ----
struct AttachOperationFunctionInfo {
const char* name;
AttachOperationFunction func;
};
+ enum AttachListenerState {
+ AL_NOT_INITIALIZED,
+ AL_INITIALIZING,
+ AL_INITIALIZED
+ };
+
class AttachListener: AllStatic {
public:
static void vm_start() NOT_SERVICES_RETURN;
static void init() NOT_SERVICES_RETURN;
static void abort() NOT_SERVICES_RETURN;
// invoke to perform clean-up tasks when all clients detach
static void detachall() NOT_SERVICES_RETURN;
+ // check unix domain socket file on filesystem
+ static bool check_socket_file() NOT_SERVICES_RETURN_(false);
+
// indicates if the Attach Listener needs to be created at startup
static bool init_at_startup() NOT_SERVICES_RETURN_(false);
// indicates if we have a trigger to start the Attach Listener
static bool is_init_trigger() NOT_SERVICES_RETURN_(false);
#if !INCLUDE_SERVICES
static bool is_attach_supported() { return false; }
#else
+
private:
! static volatile AttachListenerState _state;
public:
! static void set_state(AttachListenerState new_state) {
! Atomic::store((jlong)new_state, (volatile jlong*)&_state);
! }
!
! static AttachListenerState get_state() {
! return (AttachListenerState)Atomic::load((volatile jlong*)&_state);
! }
!
! static AttachListenerState transit_state(AttachListenerState new_state,
! AttachListenerState cmp_state) {
! return (AttachListenerState)Atomic::cmpxchg((jlong)new_state, (volatile jlong*)&_state, (jlong)cmp_state);
! }
!
! static bool is_initialized() {
! return Atomic::load((volatile jlong*)&_state) == (jlong)AL_INITIALIZED;
! }
!
! static void set_initialized() {
! Atomic::store((jlong)AL_INITIALIZED, (volatile jlong*)&_state);
! }
// indicates if this VM supports attach-on-demand
static bool is_attach_supported() { return !DisableAttachMechanism; }
// platform specific initialization
< prev index next >