-
-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Description
Hi,
If you try to start the pool which is already started (i. e. due to race condition) you get the following result
(test@localhost)1> gun_pool:start_pool("127.0.0.1", 8090, #{}).
{ok,<0.11205.0>}
(test@localhost)2> gun_pool:start_pool("127.0.0.1", 8090, #{}).
{error,{badmatch,false}}
The returned result could be clearer but it can be handled by user. You get also the nasty crash report:
2025-03-25T14:53:39.111287+01:00 [error] <0.11605.0>@gen_statem:error_info/7:2635 State machine <0.11605.0> terminating. Reason: {badmatch,false}. Stack: [{gun_pool,init,1,[{file,"/_build/default/lib/gun/src/gun_pool.erl"},{line,515}]},{gen_statem,init_it,6,[{file,"gen_statem.erl"},{line,984}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]. State: {undefined,undefined}.
2025-03-25T14:53:39.111877+01:00 [error] <0.11605.0>@proc_lib:crash_report/4:584 crasher: initial call: gun_pool:init/1, pid: <0.11605.0>, registered_name: [], error: {{badmatch,false},[{gun_pool,init,1,[{file,"/_build/default/lib/gun/src/gun_pool.erl"},{line,515}]},{gen_statem,init_it,6,[{file,"gen_statem.erl"},{line,984}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}, ancestors: [gun_pools_sup,gun_sup,<0.10161.0>], message_queue_len: 0, messages: [], links: [<0.10164.0>], dictionary: [], trap_exit: true, status: running, heap_size: 4185, stack_size: 28, reductions: 9484; neighbours:
What do you think about changing the restart strategy of gun_pools_sup from simple_one_for_one to one_for_one and using gun_pools_key(Host, Port, Opts) as unique child id. Then the duplicated start_pool call would be handled by supervisor process and result in {error, {already_started, Child :: child()}} error.
Metadata
Metadata
Assignees
Labels
No labels