google / eDistantObject

eDistantObject (eDO) - Remote invocation library for iOS
Apache License 2.0
176 stars 36 forks source link

Fix part of the TSAN flakiness of ChannelTests. #194

Closed mobile-devx-github-bot closed 4 years ago

mobile-devx-github-bot commented 4 years ago

Fix part of the TSAN flakiness of ChannelTests.

How does the flakiness happen?

If a Dispatch I/O instance has pending dispatch_io_read, the dispatch_io_close waits for the dispatch_io_read to be completed before releasing resources. However, [EDOSocketChannel -receiveDataWithHandler:] does two consecutive dispatch_io_read, so the second dispatch_io_read may corrupt dispatch_io_close when TSAN is enabled.

Proposed Fix

In [EDOSocketChannel -receiveDataWithHandler:], before performing the second dispatch_io_read, it first checks if the Dispatch I/O is still valid.