Skip to content

Commit

Permalink
Merge pull request #170 from klacke/klacke/conn_controlling_process
Browse files Browse the repository at this point in the history
Bug with controlling_process for Connection
  • Loading branch information
qzhuyan authored Jan 24, 2023
2 parents 86c901e + 9cdbb62 commit f99c2d7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/example/p_connect.lux
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

[global fail_pattern=[Ee][Rr][Rr][Oo][Rr]]
[global eprompt=\(s|c@.*\)\d*>]

[shell server]
!erl -sname s -pa ../../_build/default/lib/quicer/ebin -s qt s
?$eprompt


[shell client]
!erl -sname c -pa ../../_build/default/lib/quicer/ebin
?$eprompt
!qt:c().
?-->
!p_connect.
?Connection \# 1
?-->
!{stream, 1}.
?Stream
25 changes: 25 additions & 0 deletions test/example/qt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@ client(Conns, Streams, CNo, SNo) ->
end, lists:seq(CNo, CNo+N-1)),
client(CC ++ Conns, Streams, CNo+N, SNo);

{ok, p_connect} ->
%% Use controlling process
Self = self(),
_P = proc_lib:spawn_link(
fun() ->
case quicer:connect("localhost", Port, c_opts(), 5000) of
{ok, Conn} ->
ok = quicer:controlling_process(Conn, Self),
timer:sleep(400),
Self ! {connection, Conn};
Err ->
Self ! {connection_err, Err}
end
end),
receive
{connection, Conn} ->
io:format("Connection # ~p~n", [CNo]),
client([{Conn, CNo} | Conns], Streams, CNo+1, SNo);

{connection_err, Err} ->
io:format("Failed to connect ~p~n", [Err]),
client(Conns, Streams, CNo, SNo)
end;


{ok, {connect_stream, N}} ->
%% Create N connections, with a stream associated to each conn
L = lists:map(
Expand Down

0 comments on commit f99c2d7

Please sign in to comment.