couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [36/50] [abbrv] git commit: updated refs/heads/1843-feature-bigcouch to cba2e81
Date Sat, 29 Jun 2013 15:18:17 GMT
Correctly (don't) track sys_db files


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f9da28e4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f9da28e4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f9da28e4

Branch: refs/heads/1843-feature-bigcouch
Commit: f9da28e400bdc953ac1a8f08888bb5a4104adeab
Parents: 66809de
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Mar 13 03:52:07 2013 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Mar 20 06:02:55 2013 -0500

----------------------------------------------------------------------
 src/couch/src/couch_file.erl | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9da28e4/src/couch/src/couch_file.erl
----------------------------------------------------------------------
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index a638c32..7528091 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -23,6 +23,7 @@
 
 -record(file, {
     fd,
+    is_sys,
     eof = 0,
     db_pid
 }).
@@ -306,7 +307,7 @@ init({Filepath, Options, ReturnPid, Ref}) ->
                     ok = file:sync(Fd),
                     maybe_track_open_os_files(Options),
                     erlang:send_after(?INITIAL_WAIT, self(), maybe_close),
-                    {ok, #file{fd=Fd}};
+                    {ok, #file{fd=Fd, is_sys=lists:member(sys_db, Options)}};
                 false ->
                     ok = file:close(Fd),
                     init_status_error(ReturnPid, Ref, {error, eexist})
@@ -314,7 +315,7 @@ init({Filepath, Options, ReturnPid, Ref}) ->
             false ->
                 maybe_track_open_os_files(Options),
                 erlang:send_after(?INITIAL_WAIT, self(), maybe_close),
-                {ok, #file{fd=Fd}}
+                {ok, #file{fd=Fd, is_sys=lists:member(sys_db, Options)}}
             end;
         Error ->
             init_status_error(ReturnPid, Ref, Error)
@@ -328,7 +329,7 @@ init({Filepath, Options, ReturnPid, Ref}) ->
             maybe_track_open_os_files(Options),
             {ok, Eof} = file:position(Fd, eof),
             erlang:send_after(?INITIAL_WAIT, self(), maybe_close),
-            {ok, #file{fd=Fd, eof=Eof}};
+            {ok, #file{fd=Fd, eof=Eof, is_sys=lists:member(sys_db, Options)}};
         Error ->
             init_status_error(ReturnPid, Ref, Error)
         end
@@ -437,7 +438,7 @@ code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
 handle_info(maybe_close, File) ->
-    case is_idle() of
+    case is_idle(File) of
         true ->
             {stop, normal, File};
         false ->
@@ -446,7 +447,7 @@ handle_info(maybe_close, File) ->
     end;
 
 handle_info({'EXIT', Pid, _}, #file{db_pid=Pid}=File) ->
-    case is_idle() of
+    case is_idle(File) of
         true -> {stop, normal, File};
         false -> {noreply, File}
     end;
@@ -572,7 +573,13 @@ split_iolist([Byte | Rest], SplitAt, BeginAcc) when is_integer(Byte)
->
     split_iolist(Rest, SplitAt - 1, [Byte | BeginAcc]).
 
 
-is_idle() ->
+% System dbs aren't monitored by couch_stats_collector
+is_idle(#file{is_sys=true}) ->
+    case process_info(self(), monitored_by) of
+        {monitored_by, []} -> true;
+        _ -> false
+    end;
+is_idle(#file{is_sys=false}) ->
     case process_info(self(), monitored_by) of
         {monitored_by, []} -> true;
         {monitored_by, [_]} -> true;


Mime
View raw message