diff options
author | Dan Gudmundsson <[email protected]> | 2010-02-17 15:49:22 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-02-17 16:55:20 +0100 |
commit | f29538e8002cf0e37fa4f988fbf5484c46513bf4 (patch) | |
tree | 494a29d8a00cd872194ea3f2128a3364aa732866 /lib/ssl/test/ssl_test_lib.erl | |
parent | 8b39d0582bee5d4071b7ae4c7407d6662c0414a9 (diff) | |
download | otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.gz otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.bz2 otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.zip |
OTP-8459 Do a controlled shutdown if a non ssl packet arrives as the first
packet.
Diffstat (limited to 'lib/ssl/test/ssl_test_lib.erl')
-rw-r--r-- | lib/ssl/test/ssl_test_lib.erl | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl index 7ed19b3a05..2df2e70679 100644 --- a/lib/ssl/test/ssl_test_lib.erl +++ b/lib/ssl/test/ssl_test_lib.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -278,10 +278,10 @@ run_upgrade_server(Opts) -> TcpOptions = proplists:get_value(tcp_options, Opts), SslOptions = proplists:get_value(ssl_options, Opts), Pid = proplists:get_value(from, Opts), - + test_server:format("gen_tcp:listen(~p, ~p)~n", [Port, TcpOptions]), {ok, ListenSocket} = rpc:call(Node, gen_tcp, listen, [Port, TcpOptions]), - + case Port of 0 -> {ok, {_, NewPort}} = inet:sockname(ListenSocket), @@ -292,25 +292,29 @@ run_upgrade_server(Opts) -> test_server:format("gen_tcp:accept(~p)~n", [ListenSocket]), {ok, AcceptSocket} = rpc:call(Node, gen_tcp, accept, [ListenSocket]), - - {ok, SslAcceptSocket} = case TimeOut of - infinity -> - test_server:format("ssl:ssl_accept(~p, ~p)~n", - [AcceptSocket, SslOptions]), - rpc:call(Node, ssl, ssl_accept, - [AcceptSocket, SslOptions]); - _ -> - test_server:format("ssl:ssl_accept(~p, ~p, ~p)~n", - [AcceptSocket, SslOptions, TimeOut]), - rpc:call(Node, ssl, ssl_accept, - [AcceptSocket, SslOptions, TimeOut]) - end, - {Module, Function, Args} = proplists:get_value(mfa, Opts), - Msg = rpc:call(Node, Module, Function, [SslAcceptSocket | Args]), - Pid ! {self(), Msg}, - receive - close -> - ok = rpc:call(Node, ssl, close, [SslAcceptSocket]) + + try + {ok, SslAcceptSocket} = case TimeOut of + infinity -> + test_server:format("ssl:ssl_accept(~p, ~p)~n", + [AcceptSocket, SslOptions]), + rpc:call(Node, ssl, ssl_accept, + [AcceptSocket, SslOptions]); + _ -> + test_server:format("ssl:ssl_accept(~p, ~p, ~p)~n", + [AcceptSocket, SslOptions, TimeOut]), + rpc:call(Node, ssl, ssl_accept, + [AcceptSocket, SslOptions, TimeOut]) + end, + {Module, Function, Args} = proplists:get_value(mfa, Opts), + Msg = rpc:call(Node, Module, Function, [SslAcceptSocket | Args]), + Pid ! {self(), Msg}, + receive + close -> + ok = rpc:call(Node, ssl, close, [SslAcceptSocket]) + end + catch error:{badmatch, Error} -> + Pid ! {self(), Error} end. start_upgrade_client(Args) -> |