Skip to content

Commit

Permalink
fix: do not stop tracer process after compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth committed Oct 18, 2021
1 parent 7c1f7b8 commit fbf7270
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/mix/tasks/compile.unused.ex
Expand Up @@ -147,8 +147,6 @@ defmodule Mix.Tasks.Compile.Unused do
|> Filter.reject_matching(ignores(config))
|> Enum.sort()

:ok = Tracer.stop()

messages =
for {{m, f, a}, meta} = desc <- unused do
%Diagnostic{
Expand Down
17 changes: 11 additions & 6 deletions lib/mix_unused/tracer.ex
Expand Up @@ -16,7 +16,17 @@ defmodule MixUnused.Tracer do

@doc false
def start_link() do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
case GenServer.start_link(__MODULE__, [], name: __MODULE__) do
{:ok, _pid} = ret ->
ret

{:error, {:already_started, pid}} ->
:ets.delete_all_objects(@tab)
{:ok, pid}

other ->
other
end
end

@remote ~w[
Expand Down Expand Up @@ -75,15 +85,10 @@ defmodule MixUnused.Tracer do
:ets.select(@tab, [{{{:_, :"$1"}, :_}, [], [:"$1"]}])
end

def stop, do: GenServer.call(__MODULE__, :stop)

@impl true
def init(_args) do
_ = :ets.new(@tab, [:public, :named_table, :set, {:write_concurrency, true}])

{:ok, []}
end

@impl true
def handle_call(:stop, _, state), do: {:stop, :normal, :ok, state}
end

0 comments on commit fbf7270

Please sign in to comment.