summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2020-01-16 16:41:49 +0100
committerErlang/OTP <otp@erlang.org>2020-01-16 16:41:49 +0100
commit96591c09e7a122f83d4c34ca387a458c14d20e74 (patch)
tree0184802e7c4fef6b2d98d75b1646670d2b2e3800
parente677c99701bc36b6d1096e7013576137ae84b882 (diff)
parentca4ce23031b95ec178a1beaabc3a4dc5e738dbbe (diff)
downloaderlang-96591c09e7a122f83d4c34ca387a458c14d20e74.tar.gz
Merge branch 'hans/ssh/send_iolist/OTP-16373' into maint-20
* hans/ssh/send_iolist/OTP-16373: ssh: Change ssh_connection:send to take iodata()
-rw-r--r--lib/ssh/doc/src/ssh_connection.xml2
-rw-r--r--lib/ssh/src/ssh_connection.erl29
2 files changed, 8 insertions, 23 deletions
diff --git a/lib/ssh/doc/src/ssh_connection.xml b/lib/ssh/doc/src/ssh_connection.xml
index 150d46a9a2..f9ba5c5af9 100644
--- a/lib/ssh/doc/src/ssh_connection.xml
+++ b/lib/ssh/doc/src/ssh_connection.xml
@@ -366,7 +366,7 @@
<type>
<v>ConnectionRef = ssh_connection_ref()</v>
<v>ChannelId = ssh_channel_id()</v>
- <v>Data = binary()</v>
+ <v>Data = iodata()</v>
<v>Type = ssh_data_type_code()</v>
<v>Timeout = timeout()</v>
</type>
diff --git a/lib/ssh/src/ssh_connection.erl b/lib/ssh/src/ssh_connection.erl
index 946ae2967b..6ce3223780 100644
--- a/lib/ssh/src/ssh_connection.erl
+++ b/lib/ssh/src/ssh_connection.erl
@@ -234,32 +234,17 @@ exit_status(ConnectionHandler, Channel, Status) ->
%%--------------------------------------------------------------------
%%% Internal API
%%--------------------------------------------------------------------
-l2b(L) when is_integer(hd(L)) ->
- try list_to_binary(L)
- of
- B -> B
- catch
- _:_ ->
- unicode:characters_to_binary(L)
- end;
-l2b([H|T]) ->
- << (l2b(H))/binary, (l2b(T))/binary >>;
-l2b(B) when is_binary(B) ->
- B;
-l2b([]) ->
- <<>>.
-
-
-
-channel_data(ChannelId, DataType, Data, Connection, From)
- when is_list(Data)->
- channel_data(ChannelId, DataType, l2b(Data), Connection, From);
-
-channel_data(ChannelId, DataType, Data,
+channel_data(ChannelId, DataType, Data0,
#connection{channel_cache = Cache} = Connection,
From) ->
case ssh_channel:cache_lookup(Cache, ChannelId) of
#channel{remote_id = Id, sent_close = false} = Channel0 ->
+ Data =
+ try iolist_to_binary(Data0)
+ catch
+ _:_ ->
+ unicode:characters_to_binary(Data0)
+ end,
{SendList, Channel} =
update_send_window(Channel0#channel{flow_control = From}, DataType,
Data, Connection),