summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Switzer <dswitzer@xevo.com>2017-05-01 11:00:56 -0700
committerDavid Switzer <dswitzer@xevo.com>2017-05-01 11:00:56 -0700
commit8f699391cf02b0316851b41c182345e17e7fb36f (patch)
tree9dbbb9f09fdc924ce8cc4b4bb01f5094c1b45902
parent76d708e48cdb87bd708e9c48c9cd48b9cf97ab4b (diff)
downloadsdl_ios-8f699391cf02b0316851b41c182345e17e7fb36f.tar.gz
Additional feedback incorporated from PR.
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m5
-rwxr-xr-xSmartDeviceLink/SDLMutableDataQueue.m3
2 files changed, 8 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index abc69ab7f..a653caff1 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -172,6 +172,9 @@ int const streamOpenTimeoutSeconds = 2;
// We should be attempting to connect
self.retryCounter++;
EAAccessory *sdlAccessory = accessory;
+ // If we are being called from sdl_connectAccessory, the EAAccessoryDidConnectNotification
+ // will contain the SDL accessory to connect to and we can connect without searching the
+ // accessory manager's connected accessory list. Otherwise, we fall through to a search.
if (sdlAccessory != nil && [self sdl_connectAccessory:sdlAccessory]){
// Connection underway, exit
return;
@@ -414,6 +417,8 @@ int const streamOpenTimeoutSeconds = 2;
uint8_t buf[[SDLGlobals globals].maxMTUSize];
while (istream.streamStatus == NSStreamStatusOpen && istream.hasBytesAvailable) {
+ // It is necessary to check the stream status and whether there are bytes available because the dataStreamHasBytesHandler is executed on the IO thread and the accessory disconnect notification arrives on the main thread, causing data to be passed to the delegate while the main thread is tearing down the transport.
+
NSInteger bytesRead = [istream read:buf maxLength:[SDLGlobals globals].maxMTUSize];
NSData *dataIn = [NSData dataWithBytes:buf length:bytesRead];
diff --git a/SmartDeviceLink/SDLMutableDataQueue.m b/SmartDeviceLink/SDLMutableDataQueue.m
index 1c9b8d87f..7bc062893 100755
--- a/SmartDeviceLink/SDLMutableDataQueue.m
+++ b/SmartDeviceLink/SDLMutableDataQueue.m
@@ -31,6 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)enqueueBuffer:(NSMutableData *)data {
+ // Since this method is being called from the main thread and the dequeue methods
+ // are being called from the data session stream thread, we need to put critical
+ // sections around the queue members. Use the @synchronized object level lock to do this.
@synchronized (self) {
[self.elements addObject:data];
self.frontDequeued = NO;