From 4b5e0a20aa087dd26df644c0432627aa3e5826d4 Mon Sep 17 00:00:00 2001 From: "Damien F. Katz" Date: Wed, 6 May 2009 19:11:10 +0000 Subject: First cut at _changes api. Update the by_id and by_seq indexes to contain update seq numbers and pointers to bodies on disk, for use in the _changes api. This is a new file version, but the code can continue to serve the old 0.9 version without problems, though certain features in the _changes api will not be able to work. Upgrade to new file version (from 1 to 2) by compacting the file. Also fixed bugs with how the stats api tracks open databases. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@772406 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_file.erl | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/couchdb/couch_file.erl') diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl index b9da5488..430aa6b7 100644 --- a/src/couchdb/couch_file.erl +++ b/src/couchdb/couch_file.erl @@ -284,14 +284,16 @@ init({Filepath, Options, ReturnPid, Ref}) -> true -> {ok, 0} = file:position(Fd, 0), ok = file:truncate(Fd), - track_stats(), + couch_stats_collector:track_process_count( + {couchdb, open_os_files}), {ok, Fd}; false -> ok = file:close(Fd), init_status_error(ReturnPid, Ref, file_exists) end; false -> - track_stats(), + couch_stats_collector:track_process_count( + {couchdb, open_os_files}), {ok, Fd} end; Error -> @@ -303,7 +305,7 @@ init({Filepath, Options, ReturnPid, Ref}) -> {ok, Fd_Read} -> {ok, Fd} = file:open(Filepath, [read, write, raw, binary]), ok = file:close(Fd_Read), - track_stats(), + couch_stats_collector:track_process_count({couchdb, open_os_files}), {ok, Fd}; Error -> init_status_error(ReturnPid, Ref, Error) @@ -314,18 +316,6 @@ init({Filepath, Options, ReturnPid, Ref}) -> terminate(_Reason, _Fd) -> ok. -track_stats() -> - case (catch couch_stats_collector:increment({couchdb, open_os_files})) of - ok -> - Self = self(), - spawn( - fun() -> - erlang:monitor(process, Self), - receive {'DOWN', _, _, _, _} -> ok end, - couch_stats_collector:decrement({couchdb, open_os_files}) - end); - _ -> ok - end. handle_call({pread, Pos, Bytes}, _From, Fd) -> {reply, file:pread(Fd, Pos, Bytes), Fd}; -- cgit v1.2.3