This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch fix-erlang-21-eunit-failures in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 88a57d16ae7772b7ce18d5b1547e955f8a532358 Author: Paul J. Davis <paul.joseph.da...@gmail.com> AuthorDate: Thu Jun 21 16:23:32 2018 -0500 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. --- src/couch/src/couch_bt_engine.erl | 2 +- src/couch/src/couch_file.erl | 5 +++-- 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 43a77b0..7028997 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 9f668ea..af06b91 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);