Session cleaner is active until sessions close

The session cleaner needs to be active as long as there are active
sessions. This is what culls stale sessions, whether fully set up or
only a partial set up. The timeout needed for the next cleanup depends
on how many active sessions there are, with a faster cleanup time when
the BMC is short on resources, hoping to close idle sessions sooner.

Previously there was a corner case that did not get caught, which is
that if there is only one session, the cleaner would fail to run unless
another session started. This is because the first session would call
cleanup prior to fully activating the session, but then because it was
not activated, the cleanup code would not reschedule the cleaner.

Now the new session calls cleanup and then also schedules a clean for
later. But with each new session doing that, code needed to be added so
that during times of stress, the new sessions did not increase the next
cleaning timeout. So a new cleanup is only scheduled if one is not
already scheduled or if it is sooner than the currently scheduled
timeout.

Tested:
    ran a single RMCPP connection and waited for an idle timeout
    ran many concurrent RMCPP connections to see that the idle timeout
        decreased as the number of sessions increased.

Change-Id: I33347f62b8a14835e711bd0e7dbe6e50bb8bce64
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
1 file changed