summaryrefslogtreecommitdiff
path: root/apps/couch/src
diff options
context:
space:
mode:
authorRobert Newson <robert.newson@cloudant.com>2011-01-07 17:06:57 +0000
committerRobert Newson <robert.newson@cloudant.com>2011-01-07 17:06:57 +0000
commitbdfa34375c93e94511700150d6db09ea85915ac5 (patch)
treedab6be2a9e2b7e097e446ebad6eb41b1a0e4e6f8 /apps/couch/src
parenta14326a92817d5013c50887d52aaca10cf91d84d (diff)
Revert "11589 - explictly close file descriptor in couch_file"
This reverts commit a14326a92817d5013c50887d52aaca10cf91d84d.
Diffstat (limited to 'apps/couch/src')
-rw-r--r--apps/couch/src/couch_file.erl24
1 files changed, 14 insertions, 10 deletions
diff --git a/apps/couch/src/couch_file.erl b/apps/couch/src/couch_file.erl
index 285a04f2..b3d91bb4 100644
--- a/apps/couch/src/couch_file.erl
+++ b/apps/couch/src/couch_file.erl
@@ -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).
@@ -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),