File 0935-ftp-Handle-that-inet-ssl-setopts-can-return-error.patch of Package erlang

From 2e2e6684b797937d03b6dedd2930be0095000e22 Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Thu, 11 Jun 2020 08:28:46 +0200
Subject: [PATCH 2/3] ftp: Handle that inet/ssl:setopts can return error

---
 lib/ftp/src/ftp.erl | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/inets/src/ftp/ftp.erl b/lib/inets/src/ftp/ftp.erl
index 36b57837fc..dac316fe0b 100644
--- a/lib/inets/src/ftp/ftp.erl
+++ b/lib/inets/src/ftp/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.
 
-- 
2.26.2

openSUSE Build Service is sponsored by