< prev index next >

src/hotspot/os/solaris/attachListener_solaris.cpp

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 73,93 **** static volatile bool _has_door_path; // door descriptor returned by door_create static int _door_descriptor; ! static void set_door_path(char* path) { ! if (path == NULL) { ! _has_door_path = false; ! } else { ! strncpy(_door_path, path, PATH_MAX); ! _door_path[PATH_MAX] = '\0'; // ensure it's nul terminated ! _has_door_path = true; ! } ! } ! ! static void set_door_descriptor(int dd) { _door_descriptor = dd; } // mutex to protect operation list static mutex_t _mutex; // semaphore to wakeup listener thread --- 73,83 ---- static volatile bool _has_door_path; // door descriptor returned by door_create static int _door_descriptor; ! static bool _atexit_registered; // mutex to protect operation list static mutex_t _mutex; // semaphore to wakeup listener thread
*** 119,128 **** --- 109,131 ---- ATTACH_ERROR_RESOURCE = 102, ATTACH_ERROR_INTERNAL = 103, ATTACH_ERROR_DENIED = 104 }; + static void set_door_path(char* path) { + if (path == NULL) { + _door_path[0] = '\0'; + _has_door_path = false; + } else { + strncpy(_door_path, path, PATH_MAX); + _door_path[PATH_MAX] = '\0'; // ensure it's nul terminated + _has_door_path = true; + } + } + + static void set_door_descriptor(int dd) { _door_descriptor = dd; } + // initialize the listener static int init(); static bool has_door_path() { return _has_door_path; } static char* door_path() { return _door_path; }
*** 167,176 **** --- 170,180 ---- // statics char SolarisAttachListener::_door_path[PATH_MAX+1]; volatile bool SolarisAttachListener::_has_door_path; int SolarisAttachListener::_door_descriptor = -1; + bool SolarisAttachListener::_atexit_registered = false; mutex_t SolarisAttachListener::_mutex; sema_t SolarisAttachListener::_wakeup; SolarisAttachOperation* SolarisAttachListener::_head = NULL; SolarisAttachOperation* SolarisAttachListener::_tail = NULL;
*** 362,383 **** } // atexit hook to detach the door and remove the file extern "C" { static void listener_cleanup() { - static int cleanup_done; - if (!cleanup_done) { - cleanup_done = 1; int dd = SolarisAttachListener::door_descriptor(); if (dd >= 0) { ::close(dd); } if (SolarisAttachListener::has_door_path()) { char* path = SolarisAttachListener::door_path(); ::fdetach(path); ::unlink(path); ! } } } } // Create the door --- 366,385 ---- } // atexit hook to detach the door and remove the file extern "C" { static void listener_cleanup() { int dd = SolarisAttachListener::door_descriptor(); if (dd >= 0) { + SolarisAttachListener::set_door_descriptor(-1); ::close(dd); } if (SolarisAttachListener::has_door_path()) { char* path = SolarisAttachListener::door_path(); ::fdetach(path); ::unlink(path); ! SolarisAttachListener::set_door_path(NULL); } } } // Create the door
*** 385,395 **** --- 387,400 ---- char door_path[PATH_MAX+1]; char initial_path[PATH_MAX+1]; int fd, res; // register exit function + if (!_atexit_registered) { + _atexit_registered = true; ::atexit(listener_cleanup); + } // create the door descriptor int dd = ::door_create(enqueue_proc, NULL, 0); if (dd < 0) { return -1;
*** 641,650 **** --- 646,675 ---- } else { return false; } } + bool AttachListener::check_socket_file() { + int ret; + struct stat64 st; + ret = stat64(SolarisAttachListener::door_path(), &st); + if (ret == -1) { // need to restart attach listener. + log_debug(attach)("Door file %s does not exist - Restart Attach Listener", + SolarisAttachListener::door_path()); + + listener_cleanup(); + + // wait to terminate current attach listener instance... + while (AttachListener::transit_state(AL_INITIALIZING, + AL_NOT_INITIALIZED) != AL_NOT_INITIALIZED) { + os::naked_yield(); + } + return is_init_trigger(); + } + return false; + } + // If the file .attach_pid<pid> exists in the working directory // or /tmp then this is the trigger to start the attach mechanism bool AttachListener::is_init_trigger() { if (init_at_startup() || is_initialized()) { return false; // initialized at startup or already initialized
< prev index next >