Author: jstrachan
Date: Wed Dec 14 05:45:12 2005
New Revision: 356776
URL: http://svn.apache.org/viewcvs?rev=356776&view=rev
Log:
removed possible threading error
Modified:
incubator/activemq/trunk/activeio/src/java/org/activeio/journal/active/ControlFile.java
Modified:
incubator/activemq/trunk/activeio/src/java/org/activeio/journal/active/ControlFile.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/src/java/org/activeio/journal/active/ControlFile.java?rev=356776&r1=356775&r2=356776&view=diff
==============================================================================
---
incubator/activemq/trunk/activeio/src/java/org/activeio/journal/active/ControlFile.java
(original)
+++
incubator/activemq/trunk/activeio/src/java/org/activeio/journal/active/ControlFile.java
Wed Dec 14 05:45:12 2005
@@ -66,15 +66,15 @@
* @throws IOException
*/
public void lock() throws IOException {
- if( lock==null ) {
- Set set = getVmLockSet();
- synchronized(set) {
- if( !set.add(canonicalPath) ) {
+ Set set = getVmLockSet();
+ synchronized (set) {
+ if (lock == null) {
+ if (!set.add(canonicalPath)) {
throw new IOException("Journal is already opened by this
application.");
}
-
+
lock = channel.tryLock();
- if( lock ==null ) {
+ if (lock == null) {
set.remove(canonicalPath);
throw new IOException("Journal is already opened by
another application");
}
@@ -84,15 +84,16 @@
/**
* Un locks the control file.
- * @throws IOException
+ *
+ * @throws IOException
*/
public void unlock() throws IOException {
- if( lock != null ) {
- Set set = getVmLockSet();
- synchronized(set) {
- lock.release();
- lock=null;
+ Set set = getVmLockSet();
+ synchronized (set) {
+ if (lock != null) {
set.remove(canonicalPath);
+ lock.release();
+ lock = null;
}
}
}