fd leak in error_logger_file_h?

Hal Snyder hal@REDACTED
Fri Dec 27 09:54:10 CET 2002


> shouldn't it be something like
>
> terminate(_Reason, State) ->
>     case State of
>         {Fd, File, Prev} ->
>             close(Fd);
>         _ ->
>             true
>     end, 
>     [].

Sorry. Here's a patch against R9 that compiles:

--- lib/stdlib/src/error_logger_file_h.erl.orig	Wed Oct  2 16:15:17 2002
+++ lib/stdlib/src/error_logger_file_h.erl	Thu Dec 26 16:58:26 2002
@@ -86,7 +86,13 @@
 handle_call(_Query, State) ->
     {ok, {error, bad_query}, State}.
 
-terminate(_Reason, _State) ->
+terminate(_Reason, State) ->
+    case State of
+        {Fd, File, Prev} ->
+            file:close(Fd);
+        _ ->
+            true
+    end, 
     [].
 
 code_change(_OldVsn, State, _Extra) ->




More information about the erlang-questions mailing list