Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Revert "11589 - explictly close file descriptor in couch_file"
Browse files Browse the repository at this point in the history
This reverts commit a14326a.
  • Loading branch information
Robert Newson committed Jan 7, 2011
1 parent a14326a commit bdfa343
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions apps/couch/src/couch_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,18 @@ sync(Fd) ->
%% Returns: ok
%%----------------------------------------------------------------------
close(Fd) ->
gen_server:call(Fd, close, infinity).
MRef = erlang:monitor(process, Fd),
try
catch unlink(Fd),
catch exit(Fd, shutdown),
receive
{'DOWN', MRef, _, _, _} ->
ok
end
after
erlang:demonitor(MRef, [flush])
end.


delete(RootDir, Filepath) ->
delete(RootDir, Filepath, true).
Expand Down Expand Up @@ -278,16 +289,9 @@ maybe_track_open_os_files(FileOptions) ->
couch_stats_collector:track_process_count({couchdb, open_os_files})
end.

terminate(Reason, Fd) ->
case Reason of
normal ->
ok;
_ ->
file:close(Fd)
end.
terminate(_Reason, _Fd) ->
ok.

handle_call(close, _From, #file{fd=Fd}=File) ->
{stop, normal, file:close(Fd), File};

handle_call({pread_iolist, Pos}, _From, File) ->
{LenIolist, NextPos} = read_raw_iolist_int(File, Pos, 4),
Expand Down

0 comments on commit bdfa343

Please sign in to comment.