adium 3835:368d6f2de62c: Guard against a condition where we keep...
commits at adium.im
commits at adium.im
Sat Apr 2 23:01:50 UTC 2011
details: http://hg.adium.im/adium/rev/368d6f2de62c
revision: 3835:368d6f2de62c
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Sat Apr 02 15:43:44 2011 -0700
Guard against a condition where we keep indexing after we've passed the number of possible logs to index.
Fix crash from incorrect nil assignment to our logIndex SKIndexRef.
Subject: adium 3836:803cdc4e973d: Flush the index immediately after creating it - sets up some internal things for SearchKit
details: http://hg.adium.im/adium/rev/803cdc4e973d
revision: 3836:803cdc4e973d
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Sat Apr 02 15:50:07 2011 -0700
Flush the index immediately after creating it - sets up some internal things for SearchKit
Subject: adium 3837:07951032185e: Log indexing is less painful now, so increase the interval we save the dirty log set to disk from every 500 logs to every 2000
details: http://hg.adium.im/adium/rev/07951032185e
revision: 3837:07951032185e
branch: AILoggerWithBlocks
author: Stephen Holt <sholt at adium.im>
date: Sat Apr 02 15:58:47 2011 -0700
Log indexing is less painful now, so increase the interval we save the dirty log set to disk from every 500 logs to every 2000
diffs (154 lines):
diff -r 3aecbdcb1acf -r 07951032185e Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m Fri Apr 01 12:24:34 2011 -0700
+++ b/Source/AILogViewerWindowController.m Sat Apr 02 15:58:47 2011 -0700
@@ -605,7 +605,7 @@
if (plugin.indexIsFlushing) {
[progress appendString:AILocalizedString(@"Saving search index",nil)];
} else {
- [progress appendString:[NSString stringWithFormat:AILocalizedString(@"Indexing %lu of %lu transcripts",nil), plugin.logsIndexed, plugin.logsToIndex]];
+ [progress appendString:[NSString stringWithFormat:AILocalizedString(@"Indexing %qi of %qi transcripts",nil), plugin.logsIndexed, plugin.logsToIndex]];
}
}
diff -r 3aecbdcb1acf -r 07951032185e Source/AILoggerPlugin.h
--- a/Source/AILoggerPlugin.h Fri Apr 01 12:24:34 2011 -0700
+++ b/Source/AILoggerPlugin.h Sat Apr 02 15:58:47 2011 -0700
@@ -56,13 +56,13 @@
// publically accessable iVars
BOOL indexIsFlushing;
BOOL isIndexing;
- UInt64 logsToIndex;
- UInt64 logsIndexed;
+ SInt64 logsToIndex;
+ SInt64 logsIndexed;
}
@property(assign,readonly) BOOL indexIsFlushing;
@property(assign,readonly) BOOL isIndexing;
- at property(assign,readonly) UInt64 logsToIndex;
- at property(assign,readonly) UInt64 logsIndexed;
+ at property(assign,readonly) SInt64 logsToIndex;
+ at property(assign,readonly) SInt64 logsIndexed;
diff -r 3aecbdcb1acf -r 07951032185e Source/AILoggerPlugin.m
--- a/Source/AILoggerPlugin.m Fri Apr 01 12:24:34 2011 -0700
+++ b/Source/AILoggerPlugin.m Sat Apr 02 15:58:47 2011 -0700
@@ -70,7 +70,7 @@
//Version of the log index. Increase this number to reset everyone's index.
#define CURRENT_LOG_VERSION 9
#define LOG_INDEX_STATUS_INTERVAL 20
-#define LOG_CLEAN_SAVE_INTERVAL 500
+#define LOG_CLEAN_SAVE_INTERVAL 2000
#define NEW_LOGFILE_TIMEOUT 600
#define LOG_VIEWER AILocalizedString(@"Chat Transcript Viewer",nil)
@@ -149,8 +149,8 @@
@property(assign,readwrite) BOOL canSaveDirtyLogSet;
@property(assign,readwrite) BOOL indexIsFlushing;
@property(assign,readwrite) BOOL isIndexing;
- at property(assign,readwrite) UInt64 logsToIndex;
- at property(assign,readwrite) UInt64 logsIndexed;
+ at property(assign,readwrite) SInt64 logsToIndex;
+ at property(assign,readwrite) SInt64 logsIndexed;
@end
#pragma mark Private Function Prototypes
@@ -408,9 +408,7 @@
[self cancelIndexing];
dispatch_group_async(loggerPluginGroup, defaultDispatchQueue, ^{
- dispatch_group_enter(closingIndexGroup);
[bself _closeLogIndex];
- dispatch_group_leave(closingIndexGroup);
});
}
@@ -468,6 +466,7 @@
dispatch_sync(dirtyLogSetMutationQueue, ^{
[bself->dirtyLogSet removeAllObjects];
});
+ [bself _flushIndex:_index];
} else {
AILogWithSignature(@"AILoggerPlugin warning: SKIndexCreateWithURL() returned NULL");
}
@@ -1012,9 +1011,7 @@
BOOL dirty = NO;
NSString *contentType = [content type];
NSString *date = [[[content date] dateWithCalendarFormat:nil timeZone:nil] ISO8601DateString];
-
- dispatch_semaphore_wait(jobSemaphore, DISPATCH_TIME_FOREVER);
-
+
if ([contentType isEqualToString:CONTENT_MESSAGE_TYPE] ||
[contentType isEqualToString:CONTENT_CONTEXT_TYPE]) {
NSMutableArray *attributeKeys = [NSMutableArray arrayWithObjects:@"sender", @"time", nil];
@@ -1122,8 +1119,6 @@
AIXMLAppender *appender = [self _existingAppenderForChat:chat];
if (dirty && appender)
[bself _markLogDirtyAtPath:[appender path] forChat:chat];
-
- dispatch_semaphore_signal(jobSemaphore);
}));
}
}
@@ -1388,7 +1383,7 @@
*/
- (void)_cleanDirtyLogs
{
- __block UInt64 _remainingLogs = 0;
+ __block SInt64 _remainingLogs = 0;
//Do nothing if we're paused
if (!self.indexingAllowed) return;
@@ -1465,7 +1460,6 @@
CFRelease(documentText);
}
- dispatch_semaphore_signal(jobSemaphore);
CFRelease(document);
OSAtomicIncrement64Barrier((int64_t *)&(bself->logsIndexed));
@@ -1484,13 +1478,14 @@
OSAtomicCompareAndSwap32Barrier(unsavedChanges, 0, (int32_t *)&unsavedChanges);
}
CFRelease(searchIndex);
+ dispatch_semaphore_signal(jobSemaphore);
}));
} else {
AILogWithSignature(@"Could not create document for %@ [%@]",logPath,[NSURL fileURLWithPath:logPath]);
CFRelease(document);
- dispatch_semaphore_signal(jobSemaphore);
OSAtomicIncrement64Barrier((int64_t *)&(bself->logsIndexed));
OSAtomicIncrement32Barrier((int32_t *)&unsavedChanges);
+ dispatch_semaphore_signal(jobSemaphore);
}
CFRelease(searchIndex);
}));
@@ -1507,9 +1502,7 @@
dispatch_async(dispatch_get_main_queue(), ^{
[[AILogViewerWindowController existingWindowController] logIndexingProgressUpdate];
});
- NSLog(@"Flushing searchIndex");
- SKIndexFlush(searchIndex);
- NSLog(@"searchIndex Flushed");
+ [bself _flushIndex:searchIndex];
AILogWithSignature(@"After cleaning dirty logs, the search index has a max ID of %i and a count of %i",
SKIndexGetMaximumDocumentID(searchIndex),
SKIndexGetDocumentCount(searchIndex));
@@ -1586,13 +1579,13 @@
{
__block __typeof__(self) bself = self;
dispatch_group_wait(logIndexingGroup, DISPATCH_TIME_FOREVER);
- dispatch_async(searchIndexQueue, ^{
+ dispatch_group_async(closingIndexGroup, searchIndexQueue, ^{
if (bself->logIndex) {
[bself _flushIndex:bself->logIndex];
if (bself.canCloseIndex) {
SKIndexClose(bself->logIndex);
+ bself->logIndex = nil;
}
- bself->logIndex = nil;
}
});
}
More information about the commits
mailing list