diff options
author | Ingela Anderton Andin <[email protected]> | 2011-09-23 11:02:18 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2011-10-03 15:07:39 +0200 |
commit | e2ecc6e0db2064d072ad68b7c0a3d1bcf7c27c3a (patch) | |
tree | bf26160f7fb9401cd7374918db854bff4051b1ce /lib | |
parent | e0ab75e4206f16d8d073e9f31c487bc1d4ab84b7 (diff) | |
download | otp-e2ecc6e0db2064d072ad68b7c0a3d1bcf7c27c3a.tar.gz otp-e2ecc6e0db2064d072ad68b7c0a3d1bcf7c27c3a.tar.bz2 otp-e2ecc6e0db2064d072ad68b7c0a3d1bcf7c27c3a.zip |
Improve code structure
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssl/src/ssl_tls_dist_proxy.erl | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/lib/ssl/src/ssl_tls_dist_proxy.erl b/lib/ssl/src/ssl_tls_dist_proxy.erl index 1a998a0f34..8993582fe8 100644 --- a/lib/ssl/src/ssl_tls_dist_proxy.erl +++ b/lib/ssl/src/ssl_tls_dist_proxy.erl @@ -126,11 +126,9 @@ get_tcp_address(Socket) -> family = inet }. -accept_loop(Proxy, Type, Listen, Extra) -> +accept_loop(Proxy, erts = Type, Listen, Extra) -> process_flag(priority, max), - case Type of - erts -> - case gen_tcp:accept(Listen) of + case gen_tcp:accept(Listen) of {ok, Socket} -> Extra ! {accept,self(),Socket,inet,proxy}, receive @@ -142,30 +140,31 @@ accept_loop(Proxy, Type, Listen, Extra) -> exit(unsupported_protocol) end; Error -> - exit(Error) + exit(Error) + end, + accept_loop(Proxy, Type, Listen, Extra); + +accept_loop(Proxy, world = Type, Listen, Extra) -> + process_flag(priority, max), + case gen_tcp:accept(Listen) of + {ok, Socket} -> + Opts = get_ssl_options(server), + case ssl:ssl_accept(Socket, Opts) of + {ok, SslSocket} -> + PairHandler = + spawn_link(fun() -> + setup_connection(SslSocket, Extra) + end), + ok = ssl:controlling_process(SslSocket, PairHandler), + flush_old_controller(PairHandler, SslSocket); + _ -> + gen_tcp:close(Socket) end; - world -> - case gen_tcp:accept(Listen) of - {ok, Socket} -> - Opts = get_ssl_options(server), - case ssl:ssl_accept(Socket, Opts) of - {ok, SslSocket} -> - PairHandler = - spawn_link(fun() -> - setup_connection(SslSocket, Extra) - end), - ok = ssl:controlling_process(SslSocket, PairHandler), - flush_old_controller(PairHandler, SslSocket); - _ -> - gen_tcp:close(Socket) - end; - Error -> - exit(Error) - end + Error -> + exit(Error) end, accept_loop(Proxy, Type, Listen, Extra). - try_connect(Port) -> case gen_tcp:connect({127,0,0,1}, Port, [{active, false}, {packet,?PPRE}]) of R = {ok, _S} -> |