summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-08-17 11:13:29 -0400
committerFred Hebert <mononcqc@ferd.ca>2015-08-17 11:13:29 -0400
commitd86399d7110912a9961ff343f501db16b5b24ad4 (patch)
treea67ddd4b92bee36e9c982f56644f3acaabc2bd70 /src
parent642897867eddf00a7b1a9bf3ca99c0851b287db0 (diff)
parent278c0bdfa521a9442c814d40b90528249a77a267 (diff)
Merge pull request #720 from pvmart/master
fix leaking ets tables caused by digraphs
Diffstat (limited to 'src')
-rw-r--r--src/rebar_digraph.erl31
-rw-r--r--src/rebar_erlc_compiler.erl5
-rw-r--r--src/rebar_prv_update.erl1
3 files changed, 22 insertions, 15 deletions
diff --git a/src/rebar_digraph.erl b/src/rebar_digraph.erl
index 1132a6c..d21ff77 100644
--- a/src/rebar_digraph.erl
+++ b/src/rebar_digraph.erl
@@ -16,20 +16,23 @@ compile_order(Apps) ->
Deps = all_apps_deps(App),
add(Graph, {Name, Deps})
end, Apps),
- case digraph_utils:topsort(Graph) of
- false ->
- case digraph_utils:is_acyclic(Graph) of
- true ->
- {error, no_sort};
- false ->
- Cycles = lists:sort(
- [lists:sort(Comp) || Comp <- digraph_utils:strong_components(Graph),
- length(Comp)>1]),
- {error, {cycles, Cycles}}
- end;
- V ->
- {ok, names_to_apps(lists:reverse(V), Apps)}
- end.
+ Order =
+ case digraph_utils:topsort(Graph) of
+ false ->
+ case digraph_utils:is_acyclic(Graph) of
+ true ->
+ {error, no_sort};
+ false ->
+ Cycles = lists:sort(
+ [lists:sort(Comp) || Comp <- digraph_utils:strong_components(Graph),
+ length(Comp)>1]),
+ {error, {cycles, Cycles}}
+ end;
+ V ->
+ {ok, names_to_apps(lists:reverse(V), Apps)}
+ end,
+ true = digraph:delete(Graph),
+ Order.
add(Graph, {PkgName, Deps}) ->
case digraph:vertex(Graph, PkgName) of
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 624fe0b..4c76429 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -165,7 +165,8 @@ doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
{DepErls, OtherErls} = lists:partition(
fun(Source) -> digraph:in_degree(G, Source) > 0 end,
[File || File <- NeededErlFiles, not lists:member(File, ErlFirstFiles)]),
- DepErlsOrdered = digraph_utils:topsort(digraph_utils:subgraph(G, DepErls)),
+ SubGraph = digraph_utils:subgraph(G, DepErls),
+ DepErlsOrdered = digraph_utils:topsort(SubGraph),
FirstErls = ErlFirstFiles ++ lists:reverse(DepErlsOrdered),
?DEBUG("Files to compile first: ~p", [FirstErls]),
rebar_base_compiler:run(
@@ -177,6 +178,8 @@ doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
end,
internal_erl_compile(C, Dir, S, OutDir1, ErlOpts1)
end),
+ true = digraph:delete(SubGraph),
+ true = digraph:delete(G),
ok.
%% Get files which need to be compiled first, i.e. those specified in erl_first_files
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 049e78c..55c70e2 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -59,6 +59,7 @@ do(State) ->
ok = file:write_file(HexFile, Unzipped),
{Dict, Graph} = hex_to_graph(HexFile),
write_registry(Dict, Graph, State),
+ true = digraph:delete(Graph),
ok
catch
_E:C ->