adium 4506:f272f5b32043: It was possible that two threads were t...

commits at adium.im commits at adium.im
Fri Jan 13 20:37:57 UTC 2012


details:	http://hg.adium.im/adium/rev/f272f5b32043
revision:	4506:f272f5b32043
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Fri Jan 13 21:36:26 2012 +0100

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

diffs (33 lines):

diff -r c0dcb2b73496 -r f272f5b32043 Source/AILoggerPlugin.m
--- a/Source/AILoggerPlugin.m	Fri Jan 13 20:53:50 2012 +0100
+++ b/Source/AILoggerPlugin.m	Fri Jan 13 21:36:26 2012 +0100
@@ -430,8 +430,8 @@
 	 */
 	[self _cancelClosingLogIndex];
 	__block __typeof__(self) bself = self;
-	if (!logIndex) {
-		dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
+    dispatch_sync(searchIndexQueue, blockWithAutoreleasePool(^{
+        if (!logIndex) {
 			SKIndexRef _index = nil;
 			NSString  *logIndexPath = [bself _logIndexPath];
 			NSURL     *logIndexURL = [NSURL fileURLWithPath:logIndexPath];
@@ -480,8 +480,8 @@
 				}
 			}
 			bself->logIndex = _index;
-		}));
-	}
+		}
+    }));
 	return logIndex;
 }
 
@@ -1647,6 +1647,7 @@
 			[bself _flushIndex:bself->logIndex];
 			if (bself.canCloseIndex) {
 				SKIndexClose(bself->logIndex);
+                AILogWithSignature(@"**** Finished closing index %p", bself->logIndex);
 				bself->logIndex = nil;
 			}
 		}




More information about the commits mailing list