diff options
Diffstat (limited to 'lib/ssl')
-rw-r--r-- | lib/ssl/src/dtls_packet_demux.erl | 11 | ||||
-rw-r--r-- | lib/ssl/src/tls_socket.erl | 24 |
2 files changed, 15 insertions, 20 deletions
diff --git a/lib/ssl/src/dtls_packet_demux.erl b/lib/ssl/src/dtls_packet_demux.erl index 4945ef3c10..092366b7c0 100644 --- a/lib/ssl/src/dtls_packet_demux.erl +++ b/lib/ssl/src/dtls_packet_demux.erl @@ -298,16 +298,7 @@ do_set_emulated_opts([], Opts) -> do_set_emulated_opts([{mode, Value} | Rest], Opts) -> do_set_emulated_opts(Rest, Opts#socket_options{mode = Value}); do_set_emulated_opts([{active, N0} | Rest], Opts=#socket_options{active = Active}) when is_integer(N0) -> - N = case Active of - N1 when is_integer(N1), N0 + N1 =< 0 -> - false; - N1 when is_integer(N1) -> - N0 + N1; - _ when N0 =< 0 -> - false; - _ -> - N0 - end, + N = tls_socket:update_active_n(N0, Active), do_set_emulated_opts(Rest, Opts#socket_options{active = N}); do_set_emulated_opts([{active, Value} | Rest], Opts) -> do_set_emulated_opts(Rest, Opts#socket_options{active = Value}). diff --git a/lib/ssl/src/tls_socket.erl b/lib/ssl/src/tls_socket.erl index 9794ba39de..c3c41d3e12 100644 --- a/lib/ssl/src/tls_socket.erl +++ b/lib/ssl/src/tls_socket.erl @@ -32,6 +32,7 @@ emulated_socket_options/2, get_emulated_opts/1, set_emulated_opts/2, get_all_opts/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3]). +-export([update_active_n/2]). -record(state, { emulated_opts, @@ -334,20 +335,23 @@ split_options([Name | Opts], Emu, SocketOptNames, EmuOptNames) -> do_set_emulated_opts([], Opts) -> Opts; do_set_emulated_opts([{active, N0} | Rest], Opts) when is_integer(N0) -> - N = case proplists:lookup(active, Opts) of - {_, N1} when is_integer(N1), N0 + N1 =< 0 -> - false; - {_, N1} when is_integer(N1) -> - N0 + N1; - _ when N0 =< 0 -> - false; - _ -> - N0 - end, + N = update_active_n(N0, proplists:get_value(active, Opts, false)), do_set_emulated_opts(Rest, [{active, N} | proplists:delete(active, Opts)]); do_set_emulated_opts([{Name,_} = Opt | Rest], Opts) -> do_set_emulated_opts(Rest, [Opt | proplists:delete(Name, Opts)]). +update_active_n(New, Current) -> + if + is_integer(Current), New + Current =< 0 -> + false; + is_integer(Current) -> + New + Current; + New =< 0 -> + false; + true -> + New + end. + get_socket_opts(_, [], _) -> []; get_socket_opts(ListenSocket, SockOptNames, Cb) -> |