From 9bbf4b3899ba2185db6b4d9ba3631cb8a5491e2f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 7 Mar 2013 04:21:26 +0000 Subject: [PATCH] #5319 potential race condition when counting torrents --- macosx/Controller.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 8d6a2fb91..9cb5dce93 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -25,6 +25,7 @@ #import #import #import +#import #import "Controller.h" #import "Torrent.h" @@ -2352,7 +2353,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy if (!onLion) selectedValuesSL = [fTableView selectedValues]; - __block NSUInteger active = 0, downloading = 0, seeding = 0, paused = 0; + __block int32_t active = 0, downloading = 0, seeding = 0, paused = 0; NSString * filterType = [fDefaults stringForKey: @"Filter"]; BOOL filterActive = NO, filterDownload = NO, filterSeed = NO, filterPause = NO, filterStatus = YES; if ([filterType isEqualToString: FILTER_ACTIVE]) @@ -2381,24 +2382,24 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy { const BOOL isActive = ![torrent isStalled]; if (isActive) - ++active; + OSAtomicAdd32(1, &active); if ([torrent isSeeding]) { - ++seeding; + OSAtomicAdd32(1, &seeding); if (filterStatus && !((filterActive && isActive) || filterSeed)) return NO; } else { - ++downloading; + OSAtomicAdd32(1, &downloading); if (filterStatus && !((filterActive && isActive) || filterDownload)) return NO; } } else { - ++paused; + OSAtomicAdd32(1, &paused); if (filterStatus && !filterPause) return NO; } -- 2.40.0