Skip to content

Commit

Permalink
Removed legacy semaphores from network connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalmo Cirne committed Nov 6, 2015
1 parent 0bffa15 commit f849295
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/MPExceptionHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#import "MPMessageBuilder.h"

#if defined(MP_CRASH_REPORTER)
#import "CrashReporter.h"
#import <mParticle-CrashReporter/CrashReporter.h>
static PLCrashReporter *_crashReporter;
#endif

Expand Down
12 changes: 0 additions & 12 deletions Pod/Classes/Network/MPConnector.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ @interface MPConnector() <NSURLSessionDelegate, NSURLSessionTaskDelegate> {
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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -243,7 +238,6 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp

if (_active) {
_active = NO;
dispatch_semaphore_signal(connectionSemaphore);
}
}

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -313,8 +303,6 @@ - (void)cancelRequest {
if (_active) {
_active = NO;
[self cleariVars];

dispatch_semaphore_signal(connectionSemaphore);
}
}

Expand Down
2 changes: 0 additions & 2 deletions Pod/Classes/mParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
Expand All @@ -369,7 +368,6 @@
*** Currently unavailable ***
*/
- (void)endUncaughtExceptionLogging;
#endif

/**
Leaves a breadcrumb. Breadcrumbs are send together with crash reports to help with debugging.
Expand Down
6 changes: 4 additions & 2 deletions Pod/Classes/mParticle.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -720,8 +722,8 @@ - (void)endUncaughtExceptionLogging {
[strongSelf endUncaughtExceptionLogging];
});
}
}
#endif
}

- (void)leaveBreadcrumb:(NSString *)breadcrumbName {
[self leaveBreadcrumb:breadcrumbName eventInfo:nil];
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f849295

Please sign in to comment.