Server unused SC release fix: only last associated session is recorded
Description
A mechanism is used to release (close) Secure Channels (SC) when the number of used SCs is near the maximum. This mechanism included recording of session created on the secure channel but only the last associated session was recorded. In case this last associated session on SC was not associated to the SC anymore, the SC was considered not related to a session whereas it might be the case. The possible consequence was the SC was released (closed) and the previously associated sessions became orphaned.
Fix
Instead of keeping the last associated session for a channel, add a counter of sessions associated to a channel. A channel will then be releasable only if the number of sessions associated is 0 when it is needed.