Commits

Fred T-H  committed 3b7b4f6

fixing a bug in the termination order of user processes

  • Participants
  • Parent commits 278fcc2

Comments (0)

Files changed (1)

File src/chut_user.erl

 %%--------------------------------------------------------------------
 %% Function: terminate(UserId, Reason) -> true
 %% Description: kills the supervisor which should trickle down to the
-%% children.
+%% children. The commands to remove the supervisor are ran within an
+%% independent process. This is necessary because otherwise,
+%% terminating the user will keep it from deleting its own child spec
+%% from the chut supervisor.
 %%--------------------------------------------------------------------
 terminate(UserId) ->
-    supervisor:terminate_child(chut_user_supersup, UserId),
-    supervisor:delete_child(chut_user_supersup, UserId).
+    proc_lib:spawn(fun() ->
+        supervisor:terminate_child(chut_user_supersup, UserId),
+        supervisor:delete_child(chut_user_supersup, UserId)
+    end).
 
 %%--------------------------------------------------------------------
 %% Function: subscribe(UserId) -> {ok, HandlerId}