It was possible that two threads were trying to open the same index at the same time, so this check has to be in the dispatch_sync block.
Also, add some more logging when an index is actually closed.
Refs #13586
1.1 --- a/Source/AILoggerPlugin.m Fri Jan 13 20:53:50 2012 +0100
1.2 +++ b/Source/AILoggerPlugin.m Fri Jan 13 21:36:26 2012 +0100
1.3 @@ -430,8 +430,8 @@
1.4 */
1.5 [self _cancelClosingLogIndex];
1.6 __block __typeof__(self) bself = self;
1.7 - if (!logIndex) {
1.8 - dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
1.9 + dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
1.10 + if (!logIndex) {
1.11 SKIndexRef _index = nil;
1.12 NSString *logIndexPath = [bself _logIndexPath];
1.13 NSURL *logIndexURL = [NSURL fileURLWithPath:logIndexPath];
1.14 @@ -480,8 +480,8 @@
1.15 }
1.16 }
1.17 bself->logIndex = _index;
1.18 - }));
1.19 - }
1.20 + }
1.21 + }));
1.22 return logIndex;
1.23 }
1.24
1.25 @@ -1647,6 +1647,7 @@
1.26 [bself _flushIndex:bself->logIndex];
1.27 if (bself.canCloseIndex) {
1.28 SKIndexClose(bself->logIndex);
1.29 + AILogWithSignature(@"**** Finished closing index %p", bself->logIndex);
1.30 bself->logIndex = nil;
1.31 }
1.32 }