summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngela Anderton Andin <ingela@erlang.org>2020-06-11 08:28:46 +0200
committerIngela Anderton Andin <ingela@erlang.org>2020-06-11 10:18:21 +0200
commit2e2e6684b797937d03b6dedd2930be0095000e22 (patch)
tree479362fcca7c0ba66f9ed404543de5e2b9dd34b3
parent5a9a2fe727ba43bd6352552d42db85255b4fd4ff (diff)
downloaderlang-2e2e6684b797937d03b6dedd2930be0095000e22.tar.gz
ftp: Handle that inet/ssl:setopts can return error
-rw-r--r--lib/ftp/src/ftp.erl19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/ftp/src/ftp.erl b/lib/ftp/src/ftp.erl
index 36b57837fc..dac316fe0b 100644
--- a/lib/ftp/src/ftp.erl
+++ b/lib/ftp/src/ftp.erl
@@ -2267,12 +2267,21 @@ activate_data_connection(#state{dsock = DSock} = State) ->
State.
activate_connection(Socket) ->
- ignore_return_value(
- case socket_type(Socket) of
- tcp -> inet:setopts(unwrap_socket(Socket), [{active, once}]);
- ssl -> ssl:setopts(unwrap_socket(Socket), [{active, once}])
- end).
+ case socket_type(Socket) of
+ tcp ->
+ activate_connection(inet, tcp_closed, Socket);
+ ssl ->
+ activate_connection(ssl, ssl_closed, Socket)
+ end.
+activate_connection(API, CloseTag, Socket) ->
+ Socket = unwrap_socket(Socket),
+ case API:setopts(Socket, [{active, once}]) of
+ ok ->
+ ok;
+ {error, _} -> %% inet can retrun einval instead of closed
+ self() ! {CloseTag, Socket}
+ end.
ignore_return_value(_) -> ok.