[move] Silence some logging If a db dies becuase its fd closed then we should avoid trying to close the dead fd in couch_db:terminate/2.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/0a0f7d21 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/0a0f7d21 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/0a0f7d21 Branch: refs/heads/import Commit: 0a0f7d2194d21a90af5ee4165055b33708674757 Parents: 4547d2f Author: Paul J. Davis <[email protected]> Authored: Wed Mar 13 13:09:10 2013 -0500 Committer: Paul J. Davis <[email protected]> Committed: Fri Jan 17 16:44:32 2014 -0800 ---------------------------------------------------------------------- src/couch_db_updater.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/0a0f7d21/src/couch_db_updater.erl ---------------------------------------------------------------------- diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl index b8e150c..649826a 100644 --- a/src/couch_db_updater.erl +++ b/src/couch_db_updater.erl @@ -66,7 +66,14 @@ init({DbName, Filepath, Fd, Options}) -> terminate(_Reason, Db) -> - ok = couch_file:close(Db#db.fd), + % If the reason we died is becuase our fd disappeared + % then we don't need to try closing it again. + case Db#db.fd of + Pid when is_pid(Pid) -> + ok = couch_file:close(Db#db.fd); + _ -> + ok + end, couch_util:shutdown_sync(Db#db.compactor_pid), couch_util:shutdown_sync(Db#db.fd), ok. @@ -301,7 +308,7 @@ handle_info({'EXIT', _Pid, Reason}, Db) -> {stop, Reason, Db}; handle_info({'DOWN', Ref, _, _, Reason}, #db{fd_monitor=Ref, name=Name} = Db) -> ?LOG_ERROR("DB ~s shutting down - Fd ~p", [Name, Reason]), - {stop, normal, Db}. + {stop, normal, Db#db{fd=undefined, fd_monitor=undefined}}. code_change(_OldVsn, State, _Extra) -> {ok, State}.
