diff options
author | Sho Amano <samano@xevo.com> | 2018-08-07 11:50:43 +0900 |
---|---|---|
committer | Sho Amano <samano@xevo.com> | 2018-08-07 15:53:05 +0900 |
commit | c1883ffb63162b4a213675b841147f9bcaac9e29 (patch) | |
tree | 1d030b0a7f60cfffb7af001f4ef8962f94ad0e62 | |
parent | 253d1661293220d14f968e8bee8e966b944b4c90 (diff) | |
download | sdl_ios-c1883ffb63162b4a213675b841147f9bcaac9e29.tar.gz |
Reflect review comment
- Add assertions in I/O callback methods
-rw-r--r-- | SmartDeviceLink/SDLTCPTransport.m | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLTCPTransport.m b/SmartDeviceLink/SDLTCPTransport.m index 0d5b76500..f56641fe7 100644 --- a/SmartDeviceLink/SDLTCPTransport.m +++ b/SmartDeviceLink/SDLTCPTransport.m @@ -222,6 +222,8 @@ NSTimeInterval ConnectionTimeoutSecs = 30.0; // these methods run only on the I/O thread (i.e. invoked from the run loop) - (void)sdl_readFromStream { + NSAssert([[NSThread currentThread] isEqual:self.ioThread], @"sdl_readFromStream is called on a wrong thread!"); + BytePtr buffer = malloc(self.receiveBufferSize); NSInteger readBytes = [self.inputStream read:buffer maxLength:self.receiveBufferSize]; if (readBytes < 0) { @@ -241,6 +243,8 @@ NSTimeInterval ConnectionTimeoutSecs = 30.0; } - (void)sdl_writeToStream { + NSAssert([[NSThread currentThread] isEqual:self.ioThread], @"sdl_writeToStream is called on a wrong thread!"); + if (!self.outputStreamHasSpace || [self.sendDataQueue count] == 0) { return; } @@ -271,6 +275,8 @@ NSTimeInterval ConnectionTimeoutSecs = 30.0; } - (void)sdl_onConnectionTimedOut:(NSTimer *)timer { + NSAssert([[NSThread currentThread] isEqual:self.ioThread], @"sdl_onConnectionTimedOut is called on a wrong thread!"); + SDLLogW(@"TCP connection timed out"); [self sdl_cancelIOThread]; @@ -282,6 +288,8 @@ NSTimeInterval ConnectionTimeoutSecs = 30.0; } - (void)sdl_onStreamError:(NSStream *)stream { + NSAssert([[NSThread currentThread] isEqual:self.ioThread], @"sdl_onStreamError is called on a wrong thread!"); + // stop I/O thread [self sdl_cancelIOThread]; @@ -330,6 +338,8 @@ NSTimeInterval ConnectionTimeoutSecs = 30.0; } - (void)sdl_onStreamEnd:(NSStream *)stream { + NSAssert([[NSThread currentThread] isEqual:self.ioThread], @"sdl_onStreamEnd is called on a wrong thread!"); + [self sdl_cancelIOThread]; if (!self.transportErrorNotified) { |