You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2008/11/16 05:40:09 UTC

svn commit: r717978 - in /xml/xindice/trunk: java/src/org/apache/xindice/core/Database.java status.xml

Author: vgritsenko
Date: Sat Nov 15 20:40:08 2008
New Revision: 717978

URL: http://svn.apache.org/viewvc?rev=717978&view=rev
Log:
Fix bug #46218: race condition in shutdown sequence

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
    xml/xindice/trunk/status.xml

Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java?rev=717978&r1=717977&r2=717978&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java Sat Nov 15 20:40:08 2008
@@ -177,38 +177,40 @@
      * @return true if closed
      * @throws DBException if unable to close
      */
-    protected synchronized boolean close(boolean removeFromShutdown) throws DBException {
+    protected boolean close(boolean removeFromShutdown) throws DBException {
         if (removeFromShutdown) {
             // we have already been closed so no need to do this again.
             shutdownHandler.removeDatabase(this);
         }
 
-        // check to see if we have already been closed.
-        if (!closed) {
-            if(log.isDebugEnabled()) {
-                log.debug("Shutting down database: '" + getName() + "'");
-            }
+        synchronized (databases) {
+            databases.remove(getName());
+        }
 
-            flushConfig();
-            super.close();
+        synchronized (this) {
+            // check to see if we have already been closed.
+            if (!closed) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Shutting down database: '" + getName() + "'");
+                }
 
-            // Release database lock
-            try {
-                this.lock.close();
-                new File(getCollectionRoot(), "db.lock").delete();
-            } catch (Exception e) {
-                // Ignore IO exception
-            }
-            this.lock = null;
+                flushConfig();
+                super.close();
 
-            synchronized (databases) {
-                databases.remove(getName());
-            }
+                // Release database lock
+                try {
+                    this.lock.close();
+                    new File(getCollectionRoot(), "db.lock").delete();
+                } catch (Exception e) {
+                    // Ignore IO exception
+                }
+                this.lock = null;
 
-            // Stop the timer thread
-            timer.cancel();
+                // Stop the timer thread
+                timer.cancel();
 
-            closed = true;
+                closed = true;
+            }
         }
 
         return true;

Modified: xml/xindice/trunk/status.xml
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?rev=717978&r1=717977&r2=717978&view=diff
==============================================================================
--- xml/xindice/trunk/status.xml (original)
+++ xml/xindice/trunk/status.xml Sat Nov 15 20:40:08 2008
@@ -103,6 +103,9 @@
 
   <changes>
     <release version="1.2-dev" date="unreleased">
+      <action dev="VG" type="fix" fixes-bug="46218">
+        Fixed race condition in shutdown sequence.
+      </action>
       <action dev="VG" type="update">
         Optimized transmission of collection's symbol table between server and
         the client for reduced traffic and better performance.