From 910a25b6502150014ccbd71080d1363461406618 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 28 Feb 2011 17:51:24 +0100 Subject: Fix file descriptor leak in crashdump_viewer:chunk_page Also, remove compiler warnings for crashdump_viewer_SUITE and fix Makefile in test directory so Emakefile does not grow. --- lib/observer/src/crashdump_viewer.erl | 6 +++--- lib/observer/test/Makefile | 2 +- lib/observer/test/crashdump_viewer_SUITE.erl | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/observer/src/crashdump_viewer.erl b/lib/observer/src/crashdump_viewer.erl index 353a2db544..bf4910445b 100644 --- a/lib/observer/src/crashdump_viewer.erl +++ b/lib/observer/src/crashdump_viewer.erl @@ -2791,9 +2791,8 @@ chunk_page(SessionId,File,TW,What,HtmlCB,HtmlExtra,ParseFun) -> lookup_and_parse_index_chunk(Cont,Fd,ParseFun)) end. -chunk_page_1(Fd,HtmlInfo,SessionId,_ParseFun,done) -> - crashdump_viewer_html:chunk(SessionId,done,HtmlInfo), - close(Fd); +chunk_page_1(_Fd,HtmlInfo,SessionId,_ParseFun,done) -> + crashdump_viewer_html:chunk(SessionId,done,HtmlInfo); chunk_page_1(Fd,HtmlInfo,SessionId,ParseFun,{Chunk,Cont}) -> crashdump_viewer_html:chunk(SessionId,Chunk,HtmlInfo), chunk_page_1(Fd,HtmlInfo,SessionId,ParseFun, @@ -2802,6 +2801,7 @@ chunk_page_1(Fd,HtmlInfo,SessionId,ParseFun,{Chunk,Cont}) -> lookup_and_parse_index_chunk(Pointer,Fd,ParseFun) -> case lookup_index_chunk(Pointer) of '$end_of_table' -> + close(Fd), done; {Chunk,Cont} -> R = lists:map(fun({Id,Start}) -> diff --git a/lib/observer/test/Makefile b/lib/observer/test/Makefile index e15bde7346..6073e6ea00 100644 --- a/lib/observer/test/Makefile +++ b/lib/observer/test/Makefile @@ -53,7 +53,7 @@ EBIN = . make_emakefile: $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) \ - $(MODULES) >> $(EMAKEFILE) + $(MODULES) > $(EMAKEFILE) tests debug opt: make_emakefile cd $(ERL_TOP)/lib/test_server/src && \ diff --git a/lib/observer/test/crashdump_viewer_SUITE.erl b/lib/observer/test/crashdump_viewer_SUITE.erl index c547b997d1..8449e8a7c4 100644 --- a/lib/observer/test/crashdump_viewer_SUITE.erl +++ b/lib/observer/test/crashdump_viewer_SUITE.erl @@ -68,7 +68,7 @@ init_per_suite(doc) -> init_per_suite(Config) when is_list(Config) -> Dog = ?t:timetrap(?default_timeout), application:start(inets), % will be using the http client later - http:set_options([{ipv6,disabled}]), + httpc:set_options([{ipfamily,inet6fb4}]), DataDir = ?config(data_dir,Config), Rels = [R || R <- [r12b,r13b], ?t:is_release_available(R)] ++ [current], io:format("Creating crash dumps for the following releases: ~p", [Rels]), @@ -112,7 +112,7 @@ start(Config) when is_list(Config) -> undefined = whereis(crashdump_viewer_server), undefined = whereis(web_tool), Url = cdv_url(Port,"start_page"), - {error,_} = http:request(get,{Url,[]},[],[]), + {error,_} = httpc:request(Url), % exit(whereis(httpc_manager),kill), ?t:timetrap_cancel(AngryDog), ok. @@ -246,7 +246,7 @@ cdv_url(Port,Link) -> "http://localhost:" ++ Port ++ "/cdv_erl/crashdump_viewer/" ++ Link. request_sync(Method,HTTPReqCont) -> - case http:request(Method, + case httpc:request(Method, HTTPReqCont, [{timeout,30000}], [{full_result, false}]) of @@ -254,13 +254,13 @@ request_sync(Method,HTTPReqCont) -> Html; {ok,{Code,Html}} -> io:format("~s\n", [Html]), - io:format("Received ~w from http:request(...) with\nMethod=~w\n" + io:format("Received ~w from httpc:request(...) with\nMethod=~w\n" "HTTPReqCont=~p\n", [Code,Method,HTTPReqCont]), ?t:fail(); Other -> io:format( - "Received ~w from http:request(...) with\nMethod=~w\n" + "Received ~w from httpc:request(...) with\nMethod=~w\n" "HTTPReqCont=~p\n", [Other,Method,HTTPReqCont]), ?t:fail() @@ -497,15 +497,15 @@ expand_binary_link(Html) -> end. -next_link(Html) -> - case Html of - " - "next?pos=" ++ string:sub_word(Rest,1,$"); - [_H|T] -> - next_link(T); - [] -> - [] - end. +%% next_link(Html) -> +%% case Html of +%% " +%% "next?pos=" ++ string:sub_word(Rest,1,$"); +%% [_H|T] -> +%% next_link(T); +%% [] -> +%% [] +%% end. -- cgit v1.2.3