summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2018-06-21 16:23:32 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2018-06-21 17:17:33 -0500
commitbe9441b5147da8e66c84536b193bd4c0b9e3730a (patch)
tree6881dd8942f819ac28e74538b4dafe9da5aa8fd9
parent8229cfc0774371881708c78166ca0dacd2ea77c6 (diff)
downloadcouchdb-be9441b5147da8e66c84536b193bd4c0b9e3730a.tar.gz
Fix use of process_info(Pid, monitored_by)
This can now return references that are from NIFs monitoring the process. This is important for the new file IO NIFs that monitor the controlling process. For now we'll just take the easy way out by filtering the references from our returned monitor lists.
-rw-r--r--src/couch/src/couch_bt_engine.erl2
-rw-r--r--src/couch/src/couch_file.erl5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index 43a77b071..702899775 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -185,7 +185,7 @@ decref(St) ->
monitored_by(St) ->
case erlang:process_info(St#st.fd, monitored_by) of
{monitored_by, Pids} ->
- Pids;
+ lists:filter(fun is_pid/1, Pids);
_ ->
[]
end.
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 9f668ea69..af06b91f8 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -129,7 +129,7 @@ append_term_md5(Fd, Term, Options) ->
append_binary(Fd, Bin) ->
ioq:call(Fd, {append_bin, assemble_file_chunk(Bin)}, erlang:get(io_priority)).
-
+
append_binary_md5(Fd, Bin) ->
ioq:call(Fd,
{append_bin, assemble_file_chunk(Bin, crypto:hash(md5, Bin))},
@@ -701,7 +701,8 @@ is_idle(#file{is_sys=true}) ->
end;
is_idle(#file{is_sys=false}) ->
Tracker = whereis(couch_stats_process_tracker),
- case process_info(self(), monitored_by) of
+ {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);