From f84929560573e9a690eb96dbf73441fecc745d08 Mon Sep 17 00:00:00 2001 From: Dalmo Cirne Date: Fri, 6 Nov 2015 10:16:52 -0500 Subject: [PATCH] Removed legacy semaphores from network connections --- CHANGELOG.md | 4 +++- Pod/Classes/MPExceptionHandler.m | 2 +- Pod/Classes/Network/MPConnector.m | 12 ------------ Pod/Classes/mParticle.h | 2 -- Pod/Classes/mParticle.m | 6 ++++-- README.md | 9 +++++++++ 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d37c0621..9b9c9c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## 5.1.0 -* Support to [Crittercism](http://www.crittercism.com) as a kit +* Support for [Crittercism](http://www.crittercism.com) as a kit +* Crash reporter has been implemented as an optional subspec * Validating the authenticity of network requests by alternative means to avoid errors raised by 3rd party SDKs mutating and proxying mParticle's original object performing the request +* Removed legacy semaphores from network connections ## 5.0.2 diff --git a/Pod/Classes/MPExceptionHandler.m b/Pod/Classes/MPExceptionHandler.m index 1aaa8def..487b6ca0 100644 --- a/Pod/Classes/MPExceptionHandler.m +++ b/Pod/Classes/MPExceptionHandler.m @@ -38,7 +38,7 @@ #import "MPMessageBuilder.h" #if defined(MP_CRASH_REPORTER) - #import "CrashReporter.h" + #import static PLCrashReporter *_crashReporter; #endif diff --git a/Pod/Classes/Network/MPConnector.m b/Pod/Classes/Network/MPConnector.m index 55a4751e..740b4944 100644 --- a/Pod/Classes/Network/MPConnector.m +++ b/Pod/Classes/Network/MPConnector.m @@ -31,8 +31,6 @@ @interface MPConnector() { NSMutableData *receivedData; NSDate *requestStartTime; NSHTTPURLResponse *httpURLResponse; - dispatch_semaphore_t connectionSemaphore; - dispatch_time_t semaphoreTimeout; } @property (nonatomic, copy) void (^completionHandler)(NSData *data, NSError *error, NSTimeInterval downloadTime, NSHTTPURLResponse *httpResponse); @@ -61,8 +59,6 @@ - (id)init { _active = NO; _characterEncoding = NSUTF8StringEncoding; - connectionSemaphore = dispatch_semaphore_create(1); - semaphoreTimeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)([MPURLRequestBuilder requestTimeout] * NSEC_PER_SEC)); _connectionId = nil; [self cleariVars]; @@ -161,7 +157,6 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece if (_active) { _active = NO; [self cleariVars]; - dispatch_semaphore_signal(connectionSemaphore); } completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil); @@ -243,7 +238,6 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp if (_active) { _active = NO; - dispatch_semaphore_signal(connectionSemaphore); } } @@ -265,8 +259,6 @@ - (void)asyncGetDataFromURL:(NSURL *)url completionHandler:(void (^)(NSData *dat NSMutableURLRequest *asyncURLRequest = [[MPURLRequestBuilder newBuilderWithURL:url message:nil httpMethod:kMPHTTPMethodGet] build]; if (asyncURLRequest) { - dispatch_semaphore_wait(connectionSemaphore, semaphoreTimeout); - _active = YES; requestStartTime = [NSDate date]; self.completionHandler = completionHandler; @@ -293,8 +285,6 @@ - (void)asyncPostDataFromURL:(NSURL *)url message:(NSString *)message serialized build]; if (asyncURLRequest) { - dispatch_semaphore_wait(connectionSemaphore, semaphoreTimeout); - _active = YES; requestStartTime = [NSDate date]; self.completionHandler = completionHandler; @@ -313,8 +303,6 @@ - (void)cancelRequest { if (_active) { _active = NO; [self cleariVars]; - - dispatch_semaphore_signal(connectionSemaphore); } } diff --git a/Pod/Classes/mParticle.h b/Pod/Classes/mParticle.h index 5485a403..8196285e 100644 --- a/Pod/Classes/mParticle.h +++ b/Pod/Classes/mParticle.h @@ -357,7 +357,6 @@ - (void)logScreen:(NSString *)screenName eventInfo:(NSDictionary *)eventInfo; #pragma mark - Error, Exception, and Crash Handling -#if defined(MP_CRASH_REPORTER) /** Enables mParticle exception handling to automatically log events on uncaught exceptions. *** Currently unavailable *** @@ -369,7 +368,6 @@ *** Currently unavailable *** */ - (void)endUncaughtExceptionLogging; -#endif /** Leaves a breadcrumb. Breadcrumbs are send together with crash reports to help with debugging. diff --git a/Pod/Classes/mParticle.m b/Pod/Classes/mParticle.m index 77d778ba..a417a418 100644 --- a/Pod/Classes/mParticle.m +++ b/Pod/Classes/mParticle.m @@ -693,8 +693,8 @@ - (void)logScreen:(NSString *)screenName eventInfo:(NSDictionary *)eventInfo { } #pragma mark Error, Exception, and Crash Handling -#if defined(MP_CRASH_REPORTER) - (void)beginUncaughtExceptionLogging { +#if defined(MP_CRASH_REPORTER) if (self.backendController.initializationStatus == MPInitializationStatusStarted) { [exceptionHandler beginUncaughtExceptionLogging]; isLoggingUncaughtExceptions = YES; @@ -706,9 +706,11 @@ - (void)beginUncaughtExceptionLogging { [strongSelf beginUncaughtExceptionLogging]; }); } +#endif } - (void)endUncaughtExceptionLogging { +#if defined(MP_CRASH_REPORTER) if (self.backendController.initializationStatus == MPInitializationStatusStarted) { [exceptionHandler endUncaughtExceptionLogging]; isLoggingUncaughtExceptions = NO; @@ -720,8 +722,8 @@ - (void)endUncaughtExceptionLogging { [strongSelf endUncaughtExceptionLogging]; }); } -} #endif +} - (void)leaveBreadcrumb:(NSString *)breadcrumbName { [self leaveBreadcrumb:breadcrumbName eventInfo:nil]; diff --git a/README.md b/README.md index 87b64c8f..413c042a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,15 @@ If you do not need to build the mParticle SDK with any kit 3rd party kits, and u pod 'mParticle-iOS-SDK/mParticle' ``` +#### Crash Reporter + +The crash reporter feature has been implemented as an optional subspec. It is installed by default, however, if you are fine tunning your installation, you can choose to install it or not in your Podfile. + +```ruby +pod 'mParticle-iOS-SDK/CrashReporter' +``` + + ### Kits With each integration with a partner we strive to implement as many features as possible in the server-to-server layer, however some times a deeper integration to work side-by-side with a 3rd party SDK comes with greater benefits to our clients. We use the term **Kit** to describe such integrations.