You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mh...@apache.org on 2009/12/02 22:44:48 UTC
svn commit: r886319 - in /couchdb/trunk/src/couchdb:
couch_external_manager.erl couch_external_server.erl couch_os_process.erl
Author: mhammond
Date: Wed Dec 2 21:44:47 2009
New Revision: 886319
URL: http://svn.apache.org/viewvc?rev=886319&view=rev
Log:
COUCHDB-588: don't make log noise when an OS process chooses to terminate normally
Modified:
couchdb/trunk/src/couchdb/couch_external_manager.erl
couchdb/trunk/src/couchdb/couch_external_server.erl
couchdb/trunk/src/couchdb/couch_os_process.erl
Modified: couchdb/trunk/src/couchdb/couch_external_manager.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_external_manager.erl?rev=886319&r1=886318&r2=886319&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_external_manager.erl (original)
+++ couchdb/trunk/src/couchdb/couch_external_manager.erl Wed Dec 2 21:44:47 2009
@@ -37,6 +37,7 @@
% gen_server API
init([]) ->
+ process_flag(trap_exit, true),
Handlers = ets:new(couch_external_manager_handlers, [set, private]),
couch_config:register(fun config_change/2),
{ok, Handlers}.
@@ -81,12 +82,19 @@
handle_cast(_Whatever, State) ->
{noreply, State}.
-handle_info({'EXIT', Reason, Pid}, Handlers) ->
- ?LOG_DEBUG("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]),
+handle_info({'EXIT', Pid, normal}, Handlers) ->
+ ?LOG_INFO("EXTERNAL: Server ~p terminated normally", [Pid]),
+ % The process terminated normally without us asking - Remove Pid from the
+ % handlers table so we don't attempt to reuse it
+ ets:match_delete(Handlers, {'_', Pid}),
+ {noreply, Handlers};
+
+handle_info({'EXIT', Pid, Reason}, Handlers) ->
+ ?LOG_INFO("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]),
% Remove Pid from the handlers table so we don't try closing
% it a second time in terminate/2.
ets:match_delete(Handlers, {'_', Pid}),
- {stop, Handlers}.
+ {stop, normal, Handlers}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
Modified: couchdb/trunk/src/couchdb/couch_external_server.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_external_server.erl?rev=886319&r1=886318&r2=886319&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_external_server.erl (original)
+++ couchdb/trunk/src/couchdb/couch_external_server.erl Wed Dec 2 21:44:47 2009
@@ -34,6 +34,7 @@
init([Name, Command]) ->
?LOG_INFO("EXTERNAL: Starting process for: ~s", [Name]),
?LOG_INFO("COMMAND: ~s", [Command]),
+ process_flag(trap_exit, true),
Timeout = list_to_integer(couch_config:get("couchdb", "os_process_timeout",
"5000")),
{ok, Pid} = couch_os_process:start_link(Command, [{timeout, Timeout}]),
Modified: couchdb/trunk/src/couchdb/couch_os_process.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_os_process.erl?rev=886319&r1=886318&r2=886319&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_os_process.erl (original)
+++ couchdb/trunk/src/couchdb/couch_os_process.erl Wed Dec 2 21:44:47 2009
@@ -162,6 +162,9 @@
?LOG_DEBUG("OS Proc: Unknown cast: ~p", [Msg]),
{noreply, OsProc}.
+handle_info({Port, {exit_status, 0}}, #os_proc{port=Port}=OsProc) ->
+ ?LOG_INFO("OS Process terminated normally", []),
+ {stop, normal, OsProc};
handle_info({Port, {exit_status, Status}}, #os_proc{port=Port}=OsProc) ->
?LOG_ERROR("OS Process died with status: ~p", [Status]),
{stop, {exit_status, Status}, OsProc};