mirror of https://github.com/apache/activemq.git
removed possible threading error
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@356776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7316506346
commit
f25cc68fb1
|
@ -66,15 +66,15 @@ final public class ControlFile implements Disposable {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void lock() throws IOException {
|
public void lock() throws IOException {
|
||||||
if( lock==null ) {
|
Set set = getVmLockSet();
|
||||||
Set set = getVmLockSet();
|
synchronized (set) {
|
||||||
synchronized(set) {
|
if (lock == null) {
|
||||||
if( !set.add(canonicalPath) ) {
|
if (!set.add(canonicalPath)) {
|
||||||
throw new IOException("Journal is already opened by this application.");
|
throw new IOException("Journal is already opened by this application.");
|
||||||
}
|
}
|
||||||
|
|
||||||
lock = channel.tryLock();
|
lock = channel.tryLock();
|
||||||
if( lock ==null ) {
|
if (lock == null) {
|
||||||
set.remove(canonicalPath);
|
set.remove(canonicalPath);
|
||||||
throw new IOException("Journal is already opened by another application");
|
throw new IOException("Journal is already opened by another application");
|
||||||
}
|
}
|
||||||
|
@ -84,15 +84,16 @@ final public class ControlFile implements Disposable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Un locks the control file.
|
* Un locks the control file.
|
||||||
* @throws IOException
|
*
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void unlock() throws IOException {
|
public void unlock() throws IOException {
|
||||||
if( lock != null ) {
|
Set set = getVmLockSet();
|
||||||
Set set = getVmLockSet();
|
synchronized (set) {
|
||||||
synchronized(set) {
|
if (lock != null) {
|
||||||
lock.release();
|
|
||||||
lock=null;
|
|
||||||
set.remove(canonicalPath);
|
set.remove(canonicalPath);
|
||||||
|
lock.release();
|
||||||
|
lock = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue