summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLIAPDataSession.m
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-05-31 13:29:46 -0400
committerNicoleYarroch <nicole@livio.io>2019-05-31 13:29:46 -0400
commit8b68e7baa7fd54b39b310c22f0d6f3b6e7e6605f (patch)
treed6be342f20fa9c1e866e3b3a1ee0c2335c5a48d4 /SmartDeviceLink/SDLIAPDataSession.m
parentf8534bdec79eed921a26314b2a5bf689fbc41020 (diff)
downloadsdl_ios-8b68e7baa7fd54b39b310c22f0d6f3b6e7e6605f.tar.gz
Refactored stream errored on write in data session
Refactored the stream errored on write in data session class
Diffstat (limited to 'SmartDeviceLink/SDLIAPDataSession.m')
-rw-r--r--SmartDeviceLink/SDLIAPDataSession.m21
1 files changed, 3 insertions, 18 deletions
diff --git a/SmartDeviceLink/SDLIAPDataSession.m b/SmartDeviceLink/SDLIAPDataSession.m
index 1c046dd38..b6ec6e9dc 100644
--- a/SmartDeviceLink/SDLIAPDataSession.m
+++ b/SmartDeviceLink/SDLIAPDataSession.m
@@ -145,7 +145,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)sdl_dequeueAndWriteToOutputStream {
if ([self.ioStreamThread isCancelled]) {
- SDLLogV(@"Attempted to send data on I/O thread but the thread is cancelled.");
+ SDLLogW(@"Attempted to send data on I/O thread but the thread is cancelled.");
return;
}
@@ -166,7 +166,8 @@ NS_ASSUME_NONNULL_BEGIN
if (bytesWritten < 0) {
if (ostream.streamError != nil) {
- [self sdl_handleOutputStreamWriteError:ostream.streamError];
+ // Once a stream has reported an error, it cannot be re-used for read or write operations. Shut down the stream and attempt to create a new session.
+ [self sdl_streamDidError:ostream];
} else {
// The write operation failed but there is no further information about the error. This can occur when disconnecting from an external accessory.
SDLLogE(@"Output stream write operation failed");
@@ -180,22 +181,6 @@ NS_ASSUME_NONNULL_BEGIN
}
}
-/**
- * Handles an output stream error when attempting to write to the output stream.
- *
- * @param error The output stream error
- */
-- (void)sdl_handleOutputStreamWriteError:(NSError *)error {
- SDLLogE(@"Output stream error: %@", error);
- // TODO: We should look at the domain and the code as a tuple and decide how to handle the error based on both values. For now, if the stream is closed, we will flush the send queue and leave it as-is otherwise so that temporary error conditions can be dealt with by retrying
- if (self.eaSession == nil ||
- self.eaSession.outputStream == nil ||
- self.eaSession.outputStream.streamStatus != NSStreamStatusOpen) {
- [self.sendDataQueue removeAllObjects];
- }
-}
-
-
#pragma mark - NSStreamDelegate
/**