wohali commented on a change in pull request #665: 631 fix os proc pool eunit
URL: https://github.com/apache/couchdb/pull/665#discussion_r127047251
##########
File path: src/couch/src/couch_native_process.erl
##########
@@ -79,28 +88,38 @@ handle_call({prompt, Data}, _From, State) ->
{State, [<<"error">>, Why, Why]}
end,
+ Idle = State#evstate.idle,
case Resp of
{error, Reason} ->
Msg = io_lib:format("couch native server error: ~p", [Reason]),
- {reply, [<<"error">>, <<"native_query_server">>,
list_to_binary(Msg)], NewState};
+ Error = [<<"error">>, <<"native_query_server">>,
list_to_binary(Msg)],
+ {reply, Error, NewState, Idle};
[<<"error">> | Rest] ->
% Msg = io_lib:format("couch native server error: ~p", [Rest]),
% TODO: markh? (jan)
- {reply, [<<"error">> | Rest], NewState};
+ {reply, [<<"error">> | Rest], NewState, Idle};
[<<"fatal">> | Rest] ->
% Msg = io_lib:format("couch native server error: ~p", [Rest]),
% TODO: markh? (jan)
{stop, fatal, [<<"error">> | Rest], NewState};
Resp ->
- {reply, Resp, NewState}
+ {reply, Resp, NewState, Idle}
end.
handle_cast(garbage_collect, State) ->
erlang:garbage_collect(),
- {noreply, State};
-handle_cast(_, State) -> {noreply, State}.
+ {noreply, State, State#evstate.idle};
+handle_cast(stop, State) ->
+ {stop, normal, State};
+handle_cast(_Msg, State) ->
+ {noreply, State, State#evstate.idle}.
-handle_info({'EXIT',_,normal}, State) -> {noreply, State};
+handle_info(timeout, State) ->
+ gen_server:cast(couch_proc_manager, {os_proc_idle, self()}),
+ erlang:garbage_collect(),
Review comment:
No specific objection, but is there a specific reason we want to garbage
collect after a process times out?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services