summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2018-01-05 09:33:45 -0500
committerGitHub <noreply@github.com>2018-01-05 09:33:45 -0500
commitb7c427d8ed32bc0cfc37c84fc8f852a577a598d3 (patch)
treef7a16d172ad3a372cdd7fb86b19fe395cf81356d
parent319f618a6837eb014c44bb563f18aae55ae3708b (diff)
parentb7744bbf390a7b7e4ec41385c293ecc2a50dc371 (diff)
downloadsdl_ios-b7c427d8ed32bc0cfc37c84fc8f852a577a598d3.tar.gz
Merge pull request #832 from smartdevicelink/bugs/issue_831_iapsession_assert
Force `stop` to run on the main thread
-rw-r--r--SmartDeviceLink/SDLIAPSession.m12
1 files changed, 10 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLIAPSession.m b/SmartDeviceLink/SDLIAPSession.m
index db64bf678..33a7cf1f1 100644
--- a/SmartDeviceLink/SDLIAPSession.m
+++ b/SmartDeviceLink/SDLIAPSession.m
@@ -81,8 +81,16 @@ NSTimeInterval const StreamThreadWaitSecs = 1.0;
- (void)stop {
// This method must be called on the main thread
- NSAssert([NSThread isMainThread], @"stop must be called on the main thread");
-
+ if ([NSThread isMainThread]) {
+ [self sdl_stop];
+ } else {
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [self sdl_stop];
+ });
+ }
+}
+
+- (void)sdl_stop {
if (self.isDataSession) {
[self.ioStreamThread cancel];