lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1029348 - /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java
Date Sun, 31 Oct 2010 14:05:34 GMT
Author: mikemccand
Date: Sun Oct 31 14:05:34 2010
New Revision: 1029348

URL: http://svn.apache.org/viewvc?rev=1029348&view=rev
Log:
LUCENE-2730: fix intermittent deadlock cases, take 2

Modified:
    lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java

Modified: lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java?rev=1029348&r1=1029347&r2=1029348&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java (original)
+++ lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/index/TermsHash.java Sun Oct
31 14:05:34 2010
@@ -160,24 +160,31 @@ final class TermsHash extends InvertedDo
       nextTermsHash.flush(nextThreadsAndFields, state);
   }
 
-  synchronized public boolean freeRAM() {
+  public boolean freeRAM() {
 
     if (!trackAllocations)
       return false;
 
     boolean any;
-    final int numToFree;
-    if (postingsFreeCount >= postingsFreeChunk)
-      numToFree = postingsFreeChunk;
-    else
-      numToFree = postingsFreeCount;
-    any = numToFree > 0;
+    long bytesFreed = 0;
+    synchronized(this) {
+      final int numToFree;
+      if (postingsFreeCount >= postingsFreeChunk)
+        numToFree = postingsFreeChunk;
+      else
+        numToFree = postingsFreeCount;
+      any = numToFree > 0;
+      if (any) {
+        Arrays.fill(postingsFreeList, postingsFreeCount-numToFree, postingsFreeCount, null);
+        postingsFreeCount -= numToFree;
+        postingsAllocCount -= numToFree;
+        bytesFreed = -numToFree * bytesPerPosting;
+        any = true;
+      }
+    }
+
     if (any) {
-      Arrays.fill(postingsFreeList, postingsFreeCount-numToFree, postingsFreeCount, null);
-      postingsFreeCount -= numToFree;
-      postingsAllocCount -= numToFree;
-      docWriter.bytesAllocated(-numToFree * bytesPerPosting);
-      any = true;
+      docWriter.bytesAllocated(bytesFreed);
     }
 
     if (nextTermsHash != null)



Mime
View raw message