Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some processes were leaked after coap request #14

Open
wangzhenandy opened this issue May 27, 2017 · 1 comment
Open

Some processes were leaked after coap request #14

wangzhenandy opened this issue May 27, 2017 · 1 comment

Comments

@wangzhenandy
Copy link

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:

  1. When a client request came, the server creates 4 processes: coap_channel_sup, coap_channel, coap_responder_sup, coap_responder;
  2. Process coap_responder was closed first after finished the request;
  3. Process coap_channel was closed when the client ack timeout;
  4. Processes coap_channel_sup and coap_responder_sup could't closed;
  5. 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}};

@hejin1026
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants