From 0568a0ea0f8bf115b639589f060f62d0435a956a Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Fri, 29 Apr 2011 02:55:39 +0900 Subject: Fix file descriptor leak File descriptors to import cover data are left opened. When we export and import cover data many times, leaked descriptors cause an error. --- lib/tools/src/cover.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl index 73a736f0e8..905ad895c9 100644 --- a/lib/tools/src/cover.erl +++ b/lib/tools/src/cover.erl @@ -662,6 +662,7 @@ main_process_loop(State) -> Imported = do_import_to_table(Fd,File, State#main_state.imported), reply(From, ok), + file:close(Fd), main_process_loop(State#main_state{imported=Imported}); {error,Reason} -> reply(From, {error, {cant_open_file,File,Reason}}), -- cgit v1.2.3 From 7c1b371290b3e06834fcc4de7e5d0c89f43e818c Mon Sep 17 00:00:00 2001 From: Shunichi Shinohara Date: Fri, 6 May 2011 11:51:12 +0900 Subject: Add a check logic to prevent file descriptor leak cover module handle files as raw in export and import. Assert counts of ports are the same at the beginning and at the end of the test case. --- lib/tools/test/cover_SUITE.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl index b5c8e8a1b7..fe7f92de78 100644 --- a/lib/tools/test/cover_SUITE.erl +++ b/lib/tools/test/cover_SUITE.erl @@ -395,6 +395,7 @@ export_import(suite) -> []; export_import(Config) when is_list(Config) -> ?line DataDir = ?config(data_dir, Config), ?line ok = file:set_cwd(DataDir), + ?line PortCount = length(erlang:ports()), %% Export one module ?line {ok,f} = cover:compile(f), @@ -484,6 +485,9 @@ export_import(Config) when is_list(Config) -> ?line ?t:capture_stop(), ?line check_f_calls(1,0), + %% Check no raw files are left open + ?line PortCount = length(erlang:ports()), + %% Cleanup ?line ok = cover:stop(), ?line Files = lsfiles(), -- cgit v1.2.3