aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2011-06-28 17:08:56 +0200
committerIngela Anderton Andin <[email protected]>2011-06-28 17:08:56 +0200
commitee679e41535dd83aba7c8fb55fa12bdc6e89313c (patch)
tree609b2b36ae8ad76b77e80c999205bc736306555b
parent17f389d3d79e7c020431f3b6941cc301a977c5d8 (diff)
parent2262ba2690ba5a977576d04461bdc36f6f73d825 (diff)
downloadotp-ee679e41535dd83aba7c8fb55fa12bdc6e89313c.tar.gz
otp-ee679e41535dd83aba7c8fb55fa12bdc6e89313c.tar.bz2
otp-ee679e41535dd83aba7c8fb55fa12bdc6e89313c.zip
Merge branch 'ia/ssl/use-erlang-send-after-instead-of-timer-send-after' into dev
* ia/ssl/use-erlang-send-after-instead-of-timer-send-after: Use erlang:send_after instead of timer:send_after Conflicts: lib/ssl/test/ssl_session_cache_SUITE.erl
-rw-r--r--lib/ssl/src/ssl_manager.erl13
-rw-r--r--lib/ssl/test/ssl_session_cache_SUITE.erl26
2 files changed, 30 insertions, 9 deletions
diff --git a/lib/ssl/src/ssl_manager.erl b/lib/ssl/src/ssl_manager.erl
index 541ca1e918..371bfafae0 100644
--- a/lib/ssl/src/ssl_manager.erl
+++ b/lib/ssl/src/ssl_manager.erl
@@ -50,7 +50,8 @@
session_cache_cb,
session_lifetime,
certificate_db,
- session_validation_timer
+ session_validation_timer,
+ last_delay_timer %% Keep for testing purposes
}).
-define('24H_in_msec', 8640000).
@@ -273,15 +274,17 @@ handle_cast({invalidate_session, Host, Port,
#state{session_cache = Cache,
session_cache_cb = CacheCb} = State) ->
CacheCb:update(Cache, {{Host, Port}, ID}, Session#session{is_resumable = false}),
- timer:send_after(delay_time(), self(), {delayed_clean_session, {{Host, Port}, ID}}),
- {noreply, State};
+ TRef =
+ erlang:send_after(delay_time(), self(), {delayed_clean_session, {{Host, Port}, ID}}),
+ {noreply, State#state{last_delay_timer = TRef}};
handle_cast({invalidate_session, Port, #session{session_id = ID} = Session},
#state{session_cache = Cache,
session_cache_cb = CacheCb} = State) ->
CacheCb:update(Cache, {Port, ID}, Session#session{is_resumable = false}),
- timer:send_after(delay_time(), self(), {delayed_clean_session, {Port, ID}}),
- {noreply, State};
+ TRef =
+ erlang:send_after(delay_time(), self(), {delayed_clean_session, {Port, ID}}),
+ {noreply, State#state{last_delay_timer = TRef}};
handle_cast({recache_pem, File, LastWrite, Pid, From},
#state{certificate_db = [_, FileToRefDb, _]} = State0) ->
diff --git a/lib/ssl/test/ssl_session_cache_SUITE.erl b/lib/ssl/test/ssl_session_cache_SUITE.erl
index 2c2d88db8f..f80ac3c1a9 100644
--- a/lib/ssl/test/ssl_session_cache_SUITE.erl
+++ b/lib/ssl/test/ssl_session_cache_SUITE.erl
@@ -26,6 +26,7 @@
-include_lib("common_test/include/ct.hrl").
+-define(DELAY, 500).
-define(SLEEP, 500).
-define(TIMEOUT, 60000).
-define(LONG_TIMEOUT, 600000).
@@ -102,7 +103,7 @@ init_per_testcase(session_cleanup, Config0) ->
ssl:stop(),
application:load(ssl),
application:set_env(ssl, session_lifetime, 5),
- application:set_env(ssl, session_delay_cleanup_time, ?SLEEP),
+ application:set_env(ssl, session_delay_cleanup_time, ?DELAY),
ssl:start(),
[{watchdog, Dog} | Config];
@@ -178,7 +179,7 @@ end_per_group(_GroupName, Config) ->
%%--------------------------------------------------------------------
session_cleanup(doc) ->
["Test that sessions are cleand up eventually, so that the session table "
- "does grow and grow ..."];
+ "does not grow and grow ..."];
session_cleanup(suite) ->
[];
session_cleanup(Config)when is_list(Config) ->
@@ -211,6 +212,7 @@ session_cleanup(Config)when is_list(Config) ->
[_, _,_, _, Prop] = StatusInfo,
State = state(Prop),
Cache = element(2, State),
+ SessionTimer = element(6, State),
Id = proplists:get_value(session_id, SessionInfo),
CSession = ssl_session_cache:lookup(Cache, {{Hostname, Port}, Id}),
@@ -220,8 +222,15 @@ session_cleanup(Config)when is_list(Config) ->
true = SSession =/= undefined,
%% Make sure session has expired and been cleaned up
- test_server:sleep(5000), %% Expire time
- test_server:sleep(?SLEEP*20), %% Clean up delay (very small in this test case) + some extra time
+ check_timer(SessionTimer),
+ test_server:sleep(?DELAY), %% Delay time + some extra time
+
+ {status, _, _, StatusInfo1} = sys:get_status(whereis(ssl_manager)),
+ [_, _,_, _, Prop1] = StatusInfo1,
+ State1 = state(Prop1),
+ DelayTimer = element(7, State1),
+
+ check_timer(DelayTimer),
undefined = ssl_session_cache:lookup(Cache, {{Hostname, Port}, Id}),
undefined = ssl_session_cache:lookup(Cache, {Port, Id}),
@@ -235,6 +244,15 @@ state([{data,[{"State", State}]} | _]) ->
state([_ | Rest]) ->
state(Rest).
+check_timer(Timer) ->
+ case erlang:read_timer(Timer) of
+ false ->
+ {status, _, _, _} = sys:get_status(whereis(ssl_manager)),
+ ok;
+ Int ->
+ test_server:sleep(Int),
+ check_timer(Timer)
+ end.
%%--------------------------------------------------------------------
session_cache_process_list(doc) ->
["Test reuse of sessions (short handshake)"];