diff --git a/AppDelegate.h b/AppDelegate.h index 0124e77..1fd5d87 100755 --- a/AppDelegate.h +++ b/AppDelegate.h @@ -73,21 +73,18 @@ extern BOOL isConnected; //bottom pane view @property (weak) IBOutlet NSView *bottomPane; - -//'filter items' search box -// ->bottom pane +//'filter items' search box (bottom pane) @property (weak) IBOutlet NSSearchField *filterItemsBox; +//(main) window @property (assign) IBOutlet NSWindow *window; +//logo button @property (weak) IBOutlet NSButton *logoButton; //spinner @property (weak) IBOutlet NSProgressIndicator *progressIndicator; -//non-UI thread that performs actual scan -@property(nonatomic, strong)NSThread *scannerThread; - //filter object @property(nonatomic, retain)Filter* filterObj; diff --git a/AppDelegate.m b/AppDelegate.m index 5860f39..b4a670b 100755 --- a/AppDelegate.m +++ b/AppDelegate.m @@ -29,7 +29,6 @@ @synthesize currentTask; @synthesize searchButton; @synthesize viewSelector; -@synthesize scannerThread; @synthesize taskViewFormat; @synthesize commandHandling; @synthesize completePosting; @@ -2007,9 +2006,19 @@ bail: //select top row [self.taskTableController.itemView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; - //get tasks - // ->background thread will enum tasks, update table, etc - [self exploreTasks]; + //wait till (existing) task enumerator thread is done + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + + //wait + while(YES == [taskEnumerator.enumerator isExecuting]) + { + //nap + [NSThread sleepForTimeInterval:0.5f]; + } + + //(re)explore tasks + [self exploreTasks]; + }); return; } diff --git a/TaskEnumerator.h b/TaskEnumerator.h index ddeabce..136bc5c 100644 --- a/TaskEnumerator.h +++ b/TaskEnumerator.h @@ -28,6 +28,9 @@ /* PROPERTIES */ +//enumerator thread +@property(nonatomic, retain)NSThread* enumerator; + //all tasks objects @property(nonatomic, retain)OrderedDictionary* tasks; diff --git a/TaskEnumerator.m b/TaskEnumerator.m index aee09bd..bd4c212 100644 --- a/TaskEnumerator.m +++ b/TaskEnumerator.m @@ -14,6 +14,7 @@ @synthesize state; @synthesize tasks; @synthesize dylibs; +@synthesize enumerator; @synthesize binaryQueue; @synthesize executables; @synthesize flaggedItems; @@ -60,6 +61,10 @@ //counter int count = 0; + //save thread + // allows to be cancelled on refresh, etc + self.enumerator = [NSThread currentThread]; + //set state self.state = ENUMERATION_STATE_TASKS; @@ -71,6 +76,13 @@ // do here, and use 'new tasks' since there might be new parents too [self generateAncestries:newTasks]; + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + //only interested in one task? if(nil != pid) { @@ -129,6 +141,13 @@ }//add new tasks + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + //sort tasks if(YES != cmdlineMode) { @@ -195,7 +214,14 @@ // ->this will only reload if new task is the currently selected one, etc [((AppDelegate*)[[NSApplication sharedApplication] delegate]) reloadBottomPane:newTask itemView:CURRENT_VIEW]; } - + + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + }//signing info for all new tasks /* @@ -233,8 +259,15 @@ [newTask enumerateDylibs:self.dylibs shouldWait:NO]; } + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + //nap - [NSThread sleepForTimeInterval:0.01]; + [NSThread sleepForTimeInterval:0.05f]; } //set state @@ -269,9 +302,16 @@ //enumerate [newTask enumerateFiles:NO]; } - + + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + //nap - [NSThread sleepForTimeInterval:0.01]; + [NSThread sleepForTimeInterval:0.05f]; } //set state @@ -307,8 +347,15 @@ [newTask enumerateNetworking:NO]; } + //exit if thread was cancelled + if(YES == [[NSThread currentThread] isCancelled]) + { + //exit + [NSThread exit]; + } + //nap - [NSThread sleepForTimeInterval:0.01]; + [NSThread sleepForTimeInterval:0.05f]; } //set state diff --git a/remoteTaskService/remoteTaskService.m b/remoteTaskService/remoteTaskService.m index 241e14f..043c752 100644 --- a/remoteTaskService/remoteTaskService.m +++ b/remoteTaskService/remoteTaskService.m @@ -250,10 +250,20 @@ bail: // have to use vmmap, since we don't com.apple.system-task-ports entitlement else { + //skip self + // ...'vmmap' suspends the process + if(taskPID.intValue == getpid()) + { + //bail + goto bail; + } + //enum dylibs dylibPaths = [self enumerateDylibsNew:(NSNumber*)taskPID]; } +bail: + //invoke reply block reply(dylibPaths); diff --git a/serviceInterface.h b/serviceInterface.h index bbad03d..6d924bd 100644 --- a/serviceInterface.h +++ b/serviceInterface.h @@ -28,6 +28,4 @@ @end - - #endif