File 3438-kernel-Fix-race-condition-in-remsh-interactive-shell.patch of Package erlang

From 7df4b0c36c6bae081381b2972de588040ba9b7d9 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Mon, 8 Mar 2021 09:53:00 +0100
Subject: [PATCH 08/11] kernel: Fix race condition in remsh interactive shell
 suite

If the server node for the rcp call is slow in starting
we can end up trying to connect to early and the connection
will fail.
---
 lib/kernel/test/interactive_shell_SUITE.erl | 28 +++++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl
index 21a90babf5..5fc3e2085e 100644
--- a/lib/kernel/test/interactive_shell_SUITE.erl
+++ b/lib/kernel/test/interactive_shell_SUITE.erl
@@ -771,19 +771,27 @@ remsh_no_epmd(Config) when is_list(Config) ->
             EPMD_ARGS = "-start_epmd false -erl_epmd_port 12345 ",
             case rtstart([],"ERL_EPMD_PORT=12345 ",
                          EPMD_ARGS ++ " -sname " ++ atom_to_list(?FUNCTION_NAME)) of
-                {ok, _SRPid, _STPid, SState} ->
-                    {ok, _CRPid, CTPid, CState} =
-                        rtstart([],"ERL_EPMD_PORT=12345 ",
-                                EPMD_ARGS ++ " -remsh "++atom_to_list(?FUNCTION_NAME)),
+                {ok, _SRPid, STPid, SState} ->
                     try
                         ok = get_and_put(
-                               CTPid,
-                               [{kill_emulator_command,sigint},
-                                {putline,""},
+                               STPid,
+                               [{putline,""},
                                 {putline,"node()."},
-                                {getline_re,atom_to_list(?FUNCTION_NAME)}], 1)
+                                {getline_re,atom_to_list(?FUNCTION_NAME)}], 1),
+                            {ok, _CRPid, CTPid, CState} =
+                            rtstart([],"ERL_EPMD_PORT=12345 ",
+                                    EPMD_ARGS ++ " -remsh "++atom_to_list(?FUNCTION_NAME)),
+                        try
+                            ok = get_and_put(
+                                   CTPid,
+                                   [{kill_emulator_command,sigint},
+                                    {putline,""},
+                                    {putline,"node()."},
+                                    {getline_re,atom_to_list(?FUNCTION_NAME)}], 1)
+                        after
+                            rtstop(CState)
+                        end
                     after
-                        rtstop(CState), %% Stop client before server
                         rtstop(SState)
                     end;
                 Else ->
@@ -1206,8 +1214,6 @@ toerl_loop(#{ port := Port } = State0) ->
                 sigint ->
                     ?dbg({putdata,[$\^c]}),
                     Port ! {self(),{command, [$\^c]}},
-                    Port ! {self(),{command, [$\^c]}},
-                    Port ! {self(),{command, [$\^c]}},
                     receive
                         {Port,{data,_Data}} ->
                             ?dbg({exit_data, _Data}),
-- 
2.26.2

openSUSE Build Service is sponsored by