diff options
author | Ingela Anderton Andin <[email protected]> | 2015-11-16 21:58:36 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2015-12-03 15:54:34 +0100 |
commit | 42b8a29dbae1d626f32bc16dd81a129caf741138 (patch) | |
tree | 34773d2d761aced6cf626bb312c8041a1ecc0be6 /lib/ssl/src/ssl_session.erl | |
parent | 5e95fdff6589432327e38415fc9c5545231e7961 (diff) | |
download | otp-42b8a29dbae1d626f32bc16dd81a129caf741138.tar.gz otp-42b8a29dbae1d626f32bc16dd81a129caf741138.tar.bz2 otp-42b8a29dbae1d626f32bc16dd81a129caf741138.zip |
ssl: Add upper limit for session cache
If upper limit is reached invalidate the current cache entries, e.i the session
lifetime is the max time a session will be keept, but it may be invalidated
earlier if the max limit for the table is reached. This will keep the ssl
manager process well behaved, not exhusting memeory. Invalidating the entries
will incrementally empty the cache to make room for fresh sessions entries.
Diffstat (limited to 'lib/ssl/src/ssl_session.erl')
-rw-r--r-- | lib/ssl/src/ssl_session.erl | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/ssl/src/ssl_session.erl b/lib/ssl/src/ssl_session.erl index 0ee8a096e9..2b24bff5ff 100644 --- a/lib/ssl/src/ssl_session.erl +++ b/lib/ssl/src/ssl_session.erl @@ -61,10 +61,12 @@ client_id(ClientInfo, Cache, CacheCb, OwnCert) -> SessionId end. --spec valid_session(#session{}, seconds()) -> boolean(). +-spec valid_session(#session{}, seconds() | {invalidate_before, integer()}) -> boolean(). %% %% Description: Check that the session has not expired %%-------------------------------------------------------------------- +valid_session(#session{time_stamp = TimeStamp}, {invalidate_before, Before}) -> + TimeStamp > Before; valid_session(#session{time_stamp = TimeStamp}, LifeTime) -> Now = erlang:monotonic_time(), Lived = erlang:convert_time_unit(Now-TimeStamp, native, seconds), |