You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/02/10 21:05:32 UTC

[32/50] couch commit: updated refs/remotes/origin/import to 09c6556

[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/7047b891
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/7047b891
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/7047b891

Branch: refs/remotes/origin/import
Commit: 7047b891e2afac8a55ea56792ca5cca27449333f
Parents: 78df1c1
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Mar 13 13:09:10 2013 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Tue Feb 4 17:03:25 2014 -0600

----------------------------------------------------------------------
 src/couch_db_updater.erl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7047b891/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}.