You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2018/10/03 22:33:18 UTC

[couchdb] branch erlang-21-support updated: Fix monitored_by fix for couch_file

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch erlang-21-support
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/erlang-21-support by this push:
     new 338f3b9  Fix monitored_by fix for couch_file
338f3b9 is described below

commit 338f3b93b9291299359c9a8e3cc4ca21244d162d
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed Oct 3 18:32:37 2018 -0400

    Fix monitored_by fix for couch_file
---
 src/couch/src/couch_file.erl | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index cfa07d8..247436f 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -695,20 +695,22 @@ split_iolist([Sublist| Rest], SplitAt, BeginAcc) when is_list(Sublist) ->
 split_iolist([Byte | Rest], SplitAt, BeginAcc) when is_integer(Byte) ->
     split_iolist(Rest, SplitAt - 1, [Byte | BeginAcc]).
 
+monitored_by_pids() ->
+    {monitored_by, PidsAndRefs} = process_info(self(), monitored_by),
+    lists:filter(fun is_pid/1, PidsAndRefs).
 
 % System dbs aren't monitored by couch_stats_process_tracker
 is_idle(#file{is_sys=true}) ->
-    case process_info(self(), monitored_by) of
-        {monitored_by, []} -> true;
+    case monitored_by_pids() of
+        [] -> true;
         _ -> false
     end;
 is_idle(#file{is_sys=false}) ->
     Tracker = whereis(couch_stats_process_tracker),
-    {monitored_by, PidsAndRefs} = process_info(self(), monitored_by),
-    case lists:filter(fun is_pid/1, PidsAndRefs) of
-        {monitored_by, []} -> true;
-        {monitored_by, [Tracker]} -> true;
-        {monitored_by, [_]} -> exit(tracker_monitoring_failed);
+    case monitored_by_pids() of
+        [] -> true;
+        [Tracker] -> true;
+        [_] -> exit(tracker_monitoring_failed);
         _ -> false
     end.