Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to allow for reentrant parsing iOS 8 #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update to allow for reentrant parsing iOS 8
In iOS 8, an occasional bug after reentrant parsing could occur, in which NSXML in the feed parser would crash due to non-existent thread safety. This fixes this.
  • Loading branch information
TheHexagon committed Mar 6, 2015
commit c1caea9073af92e75085307d7b0b040c2bf3ce2a
11 changes: 9 additions & 2 deletions Classes/MWFeedParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,22 @@ - (void)startParsingData:(NSData *)data textEncodingName:(NSString *)textEncodin

// Create NSXMLParser
if (data) {
dispatch_queue_t reentrantAvoidanceQueue = dispatch_queue_create("reentrantAvoidanceQueue", DISPATCH_QUEUE_SERIAL);
dispatch_async(reentrantAvoidanceQueue, ^{
NSXMLParser *newFeedParser = [[NSXMLParser alloc] initWithData:data];
self.feedParser = newFeedParser;
});
dispatch_sync(reentrantAvoidanceQueue, ^{ });
if (feedParser) {

dispatch_queue_t reentrantAvoidanceQueue = dispatch_queue_create("reentrantAvoidanceQueue", DISPATCH_QUEUE_SERIAL);
dispatch_async(reentrantAvoidanceQueue, ^{
// Parse!
feedParser.delegate = self;
[feedParser setShouldProcessNamespaces:YES];
[feedParser parse];
self.feedParser = nil; // Release after parse
});
dispatch_sync(reentrantAvoidanceQueue, ^{ })

} else {
[self parsingFailedWithErrorCode:MWErrorCodeFeedParsingError andDescription:@"Feed not a valid XML document"];
Expand Down Expand Up @@ -946,4 +953,4 @@ - (BOOL)processAtomLink:(NSDictionary *)attributes andAddToMWObject:(id)MWObject
return NO;
}

@end
@end