From 99033bc070be6325ccbbb0a3e7e69396c8a30ec9 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 23 Mar 2011 16:07:03 +0100 Subject: Never fail when stopping rb, and fix file descriptor leak rb:stop did sometimes return {error,running}. This came from supervisor:delete_child and happened when the rb_server has not yet terminated when this function was called. Instead of having a separate gen_server call to rb_server for stopping the process, supervisor:terminate_child is now called. This is a synchronous function - i.e. it waits for the process to actually terminate before it returns. A file descriptor leak in rb:scan_files is corrected. The index file was never closed after reading. --- lib/sasl/src/rb.erl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/sasl') diff --git a/lib/sasl/src/rb.erl b/lib/sasl/src/rb.erl index 13753565d8..500c795721 100644 --- a/lib/sasl/src/rb.erl +++ b/lib/sasl/src/rb.erl @@ -53,7 +53,7 @@ start_link(Options) -> gen_server:start_link({local, rb_server}, rb, Options, []). stop() -> - call(stop), + supervisor:terminate_child(sasl_sup, rb_server), supervisor:delete_child(sasl_sup, rb_server). rescan() -> rescan([]). @@ -205,8 +205,6 @@ handle_call({rescan, Options}, _From, State) -> NewState = State#state{data = Data, max = Max, type = Type, device = Device, abort = Abort, log = Log1}, {reply, ok, NewState}; -handle_call(stop, _From, State) -> - {stop, normal, stopped, State}; handle_call(_, _From, #state{data = undefined}) -> {reply, {error, no_data}, #state{}}; handle_call({list, Type}, _From, State) -> @@ -312,11 +310,14 @@ scan_files(RptDir, Max, Type) -> {ok, Fd} -> case catch file:read(Fd, 1) of {ok, [LastWritten]} -> + file:close(Fd), Files = make_file_list(RptDir, LastWritten), scan_files(RptDir, Files, Max, Type); - _ -> exit("cannot read the index file") + _X -> + file:close(Fd), + exit("cannot read the index file") end; - _ -> exit("cannot read the index file") + _X -> exit("cannot read the index file") end. make_file_list(Dir, FirstFileNo) -> -- cgit v1.2.3 From de5377beb78d2fc0f0bea964fb9244722492a448 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 1 Apr 2011 16:36:08 +0200 Subject: Don't attempt to do supervisor:delete_child for temporary child After a bug fix supervisor does no longer save childspecs for temporary children. Due to this, all calls to supervisor:delete_child will fail for temporary children. rb:stop is therefore now rewritten to only do supervisor:terminate_child. --- lib/sasl/src/rb.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/sasl') diff --git a/lib/sasl/src/rb.erl b/lib/sasl/src/rb.erl index 500c795721..5fdb0b1695 100644 --- a/lib/sasl/src/rb.erl +++ b/lib/sasl/src/rb.erl @@ -53,8 +53,7 @@ start_link(Options) -> gen_server:start_link({local, rb_server}, rb, Options, []). stop() -> - supervisor:terminate_child(sasl_sup, rb_server), - supervisor:delete_child(sasl_sup, rb_server). + supervisor:terminate_child(sasl_sup, rb_server). rescan() -> rescan([]). rescan(Options) -> -- cgit v1.2.3 From b1dd3337729aa9340dba45c194c1896944262376 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 13 May 2011 10:13:29 +0200 Subject: Bugfix in rb:filter when using 're' (regexp) and 'no' There was an inconsistency in the filter function, as filter([{Key,Regexp,re,no}]) did not work in the same way as filter([{Key,Value,no}]) The first filter only returned 'proplist' reports, while the second returned *all* reports that didn't match the Value. This has been corrected so both filters now return all reports that don't match. --- lib/sasl/src/rb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sasl') diff --git a/lib/sasl/src/rb.erl b/lib/sasl/src/rb.erl index 5fdb0b1695..8004ef2c5a 100644 --- a/lib/sasl/src/rb.erl +++ b/lib/sasl/src/rb.erl @@ -789,7 +789,7 @@ filter_report([{Key, RegExp, re}|T], Msg) -> filter_report([{Key, RegExp, re, no}|T], Msg) -> case proplists:get_value(Key, Msg) of undefined -> - false; + true; Value -> Subject = lists:flatten(io_lib:format("~p",[Value])), case run_re(Subject, RegExp) of -- cgit v1.2.3