Synchronize SC state between SC and services layers to avoid unexpected access to config/state
Description
Due to unsynchronized server SC state between SC and Services layers, unexpected access to SC configuration / instance might occur leading to raise an assertion in S2OPC server (see #1197 (closed)). It is necessary to synchronize the state from SC layer to Services layer when SC is closed, and then the Services layer to acknowledge state is synchronized to the SC layer prior to free the SC config and instances for further re-use.
Implementation
SC layer:
- do not remove SC configuration on SC close
- set SC instance state to a new SECURE_CONNECTION_STATE_SC_CLOSING state until state is synchronized with Services layer
- add an SC_DISCONNECTED_ACK acknowledgment event from Services layer and free SC configuration and instance when received
Service layer:
- generate an an SC_DISCONNECTED_ACK event to SC layer after treatment of an SC_DISCONNECTED event