Bug Fix: Operation blocks should queue inputs
Operation blocks cannot expect their out of scope variables to be present when the block executes, so design the block operation to pull inputs from a queue array one at a time, like the rest of the blocks do. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
14a8a35dac
commit
3874d65ec2
1 changed files with 15 additions and 4 deletions
|
@ -908,12 +908,19 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path);
|
||||||
__block id<SentrySpan> mainTask = [SentrySDK startTransactionWithName:@"Loading tags" operation:@"Main tag operation"];
|
__block id<SentrySpan> mainTask = [SentrySDK startTransactionWithName:@"Loading tags" operation:@"Main tag operation"];
|
||||||
|
|
||||||
{
|
{
|
||||||
for(NSString *key in queueThisJob) {
|
__block NSLock *blockLock = [[NSLock alloc] init];
|
||||||
|
__block NSMutableArray *blockInputs = [queueThisJob mutableCopy];
|
||||||
|
for(size_t i = 0, j = [blockInputs count]; i < j; ++i) {
|
||||||
NSBlockOperation *op = [[NSBlockOperation alloc] init];
|
NSBlockOperation *op = [[NSBlockOperation alloc] init];
|
||||||
NSURL *url = urlForPath(key);
|
|
||||||
|
|
||||||
[op addExecutionBlock:^{
|
[op addExecutionBlock:^{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
[blockLock lock];
|
||||||
|
NSString *key = [blockInputs objectAtIndex:0];
|
||||||
|
[blockInputs removeObjectAtIndex:0];
|
||||||
|
[blockLock unlock];
|
||||||
|
|
||||||
|
NSURL *url = urlForPath(key);
|
||||||
|
|
||||||
NSString *message = [NSString stringWithFormat:@"Loading metadata for %@", url];
|
NSString *message = [NSString stringWithFormat:@"Loading metadata for %@", url];
|
||||||
DLog(@"%@", message);
|
DLog(@"%@", message);
|
||||||
id<SentrySpan> childTask = nil;
|
id<SentrySpan> childTask = nil;
|
||||||
|
@ -947,7 +954,11 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path);
|
||||||
}
|
}
|
||||||
@catch(NSException *e) {
|
@catch(NSException *e) {
|
||||||
DLog(@"Exception thrown while reading tags: %@", e);
|
DLog(@"Exception thrown while reading tags: %@", e);
|
||||||
[SentrySDK captureException:e];
|
if(e) {
|
||||||
|
[SentrySDK captureException:e];
|
||||||
|
} else {
|
||||||
|
[SentrySDK captureMessage:[NSString stringWithFormat:@"Null exception caught while reading tags for URL: %@", url]];
|
||||||
|
}
|
||||||
if(childTask) {
|
if(childTask) {
|
||||||
[childTask finishWithStatus:kSentrySpanStatusInternalError];
|
[childTask finishWithStatus:kSentrySpanStatusInternalError];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue