--- a/Source/AILoggerPlugin.m Wed Jun 20 22:55:37 2012 +0200
+++ b/Source/AILoggerPlugin.m Wed Jun 20 23:24:21 2012 +0200
@@ -1440,10 +1440,13 @@
OSAtomicCompareAndSwap64Barrier(logsIndexed, 0, (int64_t*)&logsIndexed);
if (self.indexingAllowed) {
__block UInt32 lastUpdate = TickCount();
__block SInt32 unsavedChanges = 0;
@@ -1451,7 +1454,9 @@
AILogWithSignature(@"Cleaning %i dirty logs", [localLogSet count]);
dispatch_group_async(loggerPluginGroup, searchIndexQueue, blockWithAutoreleasePool(^{
dispatch_group_enter(logIndexingGroup);
while (_remainingLogs > 0 && bself.indexingAllowed) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
__block NSString *__logPath = nil;
@@ -1535,6 +1540,9 @@
dispatch_semaphore_signal(jobSemaphore);
+ OSAtomicIncrement64Barrier((int64_t *)&(bself->logsIndexed)); + OSAtomicDecrement64Barrier((int64_t *)&_remainingLogs); dispatch_semaphore_signal(jobSemaphore);
@@ -1550,6 +1558,7 @@
AILogWithSignature(@"Could not create document for %@ [%@]",logPath,[NSURL fileURLWithPath:logPath]);
if (document) CFRelease(document);
OSAtomicIncrement64Barrier((int64_t *)&(bself->logsIndexed));
+ OSAtomicDecrement64Barrier((int64_t *)&_remainingLogs); OSAtomicIncrement32Barrier((int32_t *)&unsavedChanges);
dispatch_semaphore_signal(jobSemaphore);
dispatch_semaphore_signal(logLoadingPrefetchSemaphore);
@@ -1563,6 +1572,7 @@
[bself _saveDirtyLogSet];
+ dispatch_group_enter(closingIndexGroup); dispatch_group_leave(logIndexingGroup);
dispatch_group_notify(logIndexingGroup, searchIndexQueue, ^{
dispatch_async(dispatch_get_main_queue(), ^{
@@ -1572,10 +1582,14 @@
AILogWithSignature(@"After cleaning dirty logs, the search index has a max ID of %i and a count of %i",
SKIndexGetMaximumDocumentID(searchIndex),
SKIndexGetDocumentCount(searchIndex));
+ CFRelease(searchIndex); [bself _didCleanDirtyLogs];
+ dispatch_group_leave(closingIndexGroup); + CFRelease(searchIndex); @@ -1649,7 +1663,7 @@
[bself _flushIndex:bself->logIndex];
if (bself.canCloseIndex) {
SKIndexClose(bself->logIndex);
- AILogWithSignature(@"**** Finished closing index %p", bself->logIndex);
+ AILogWithSignature(@"**** %@ Released its index %p", bself, bself->logIndex); @@ -1666,7 +1680,7 @@
- AILogWithSignature(@"**** Finished flushing index %p, and released it",inIndex);
+ AILogWithSignature(@"**** Finished flushing index %p",inIndex); self.indexIsFlushing = NO;