smartdevicelink / sdl_core

SmartDeviceLink In-Vehicle Software and Sample HMI
BSD 3-Clause "New" or "Revised" License
241 stars 244 forks source link

Fix ThreadedSocket disconnect logic #3566

Closed AKalinich-Luxoft closed 2 years ago

AKalinich-Luxoft commented 4 years ago

Fixes https://github.com/smartdevicelink/sdl_core/issues/3561

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

Covered by ATF scripts

Summary

There was noticed an issue with ThreadedSocket connection which often closes connection like an "unexpected disconnect" calling ConnectionAborted() every time even if it is handled disconnect. Also, there were no any events raised to Transport Manager for rare cases when connect is expected. To fix that, flow has been separated for handling expected and unexpected disconnect. Expected disconnect will be handled in case when external component calls Disconnect() and socket thread is alive. In that case should be called DisconnectDone() when thread is stopped. Unexpected disconnect will be handled in case when internal thread has been aborted and Abort() was called. In that case internal thread ConnectionAborted() will be called from internal thread to notify Transport Manager that physical disconnect has happened. This issue is pretty hard to detect just because business logic handles both disconnect types in the same way for now, but this might be changed in the future.

CLA