gen_coap
gen_coap copied to clipboard
Some processes were leaked after coap request
Hello,
I Found the processes of coap_channel_sup
and coap_responder_sup
can't be closed after coap request socket closed.
I test it like:
- When a client request came, the server creates 4 processes:
coap_channel_sup
,coap_channel
,coap_responder_sup
,coap_responder
; - Process
coap_responder
was closed first after finished the request; - Process
coap_channel
was closed when the client ack timeout; - Processes
coap_channel_sup
andcoap_responder_sup
could't closed; - The two processed above will not be reused.
The code in file coap_udp_socker.erl is like: handle_info({terminated, SupPid, ChId}, State=#state{chans=Chans}) -> Chans2 = dict:erase(ChId, Chans), exit(SupPid, normal), {noreply, State#state{chans=Chans2}};
is it right to change it like this? handle_info({terminated, SupPid, ChId}, State=#state{chans=Chans, pool=PoolPid}) -> Chans2 = dict:erase(ChId, Chans), exit(SupPid, normal), coap_channel_sup_sup:delete_channel(PoolPid, ChId), {noreply, State#state{chans=Chans2}};
exit(SupPid, normal) but SupPid(coap_channel_sup) can not exit because
If Reason is the atom normal, Pid does not exit. If it is trapping exits, the exit signal is transformed into a message {'EXIT', From, normal} and delivered to its message queue.
so why use exit(SupPid, normal), it not work exit(SupPid, kill) and coap_channel_sup_sup:delete_channel(PoolPid, ChId) can make SupPid shutdown is that right?