Skip to content

Commit 7d08b45

Browse files
committed
Merge branch 'maint'
* maint: epmd_SUITE: Fix a deprecation warning epmd_SUITE: Cuddle slow_get_port_nr/1
2 parents 498708c + ff4a183 commit 7d08b45

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

erts/epmd/test/epmd_SUITE.erl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,11 @@ parse_line([$n,$a,$m,$e,$ | Buf0]) ->
374374
{Name, Buf1} ->
375375
case Buf1 of
376376
[$a,$t,$ ,$p,$o,$r,$t,$ | Buf2] ->
377-
case catch list_to_integer(Buf2) of
378-
{'EXIT', _} -> error;
377+
try list_to_integer(Buf2) of
379378
Port -> {ok, {Name, Port}}
379+
catch
380+
_:_ ->
381+
error
380382
end;
381383
_ -> error
382384
end;
@@ -398,7 +400,13 @@ get_port_nr(Config) when is_list(Config) ->
398400

399401
%% Register with slow write and ask about port nr
400402
slow_get_port_nr(Config) when is_list(Config) ->
401-
port_request([?EPMD_PORT2_REQ,d,$f,d,$o,d,$o]).
403+
%% Pause for 200ms. The packet timeout is 1 second as per ?EPMDARGS defined
404+
%% above.
405+
Pause = {pause, 200},
406+
port_request([?EPMD_PORT2_REQ,
407+
Pause,$f,
408+
Pause,$o,
409+
Pause,$o]).
402410

403411

404412
% Internal function used above
@@ -1024,9 +1032,8 @@ recv(Sock, Len, Timeout) ->
10241032
exit(1)
10251033
end.
10261034

1027-
%% Send data to socket. The list can be non flat and contain
1028-
%% the atom 'd' or tuple {d,Seconds} where this is delay
1029-
%% put in between the sent characters.
1035+
%% Send data to socket. The list can be nested and contain {pause,Milliseconds}
1036+
%% to pause that many milliseconds before sending the next character.
10301037

10311038
send(Sock, SendSpec) ->
10321039
case send(SendSpec, [], Sock) of
@@ -1055,12 +1062,10 @@ send([List | Spec], RevBytes, Sock) when is_list(List) ->
10551062
Other ->
10561063
Other
10571064
end;
1058-
send([d | Spec], RevBytes, Sock) ->
1059-
send([{d,1000} | Spec], RevBytes, Sock);
1060-
send([{d,S} | Spec], RevBytes, Sock) ->
1065+
send([{pause, Ms} | Spec], RevBytes, Sock) ->
10611066
case send_direct(Sock, lists:reverse(RevBytes)) of
10621067
ok ->
1063-
timer:sleep(S),
1068+
timer:sleep(Ms),
10641069
send(Spec, [], Sock);
10651070
Any ->
10661071
Any

0 commit comments

Comments
 (0)