Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A12BC6D9 for ; Thu, 7 Aug 2014 15:37:25 +0000 (UTC) Received: (qmail 86201 invoked by uid 500); 7 Aug 2014 15:37:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 86156 invoked by uid 500); 7 Aug 2014 15:37:25 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 86146 invoked by uid 99); 7 Aug 2014 15:37:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 15:37:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D8A729C29A4; Thu, 7 Aug 2014 15:37:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Thu, 07 Aug 2014 15:37:31 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/50] couch commit: updated refs/heads/windsor-merge to 6e60cbe Improve code_change and #proc{} imports Going forward we should define default values for all fields of a proc_int that are not shared by a proc. This allows us to implement the general import_proc/1 function that I've added (and used in code_change) here. BugzID: 19529 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/08a25ad7 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/08a25ad7 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/08a25ad7 Branch: refs/heads/windsor-merge Commit: 08a25ad7d43c83169120ccce64256a5028718490 Parents: acb80ab Author: Adam Kocoloski Authored: Tue Jun 4 16:36:22 2013 -0400 Committer: Robert Newson Committed: Tue Aug 5 12:03:15 2014 +0100 ---------------------------------------------------------------------- src/couch_proc_manager.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/08a25ad7/src/couch_proc_manager.erl ---------------------------------------------------------------------- diff --git a/src/couch_proc_manager.erl b/src/couch_proc_manager.erl index 8cb53cb..f84c06a 100644 --- a/src/couch_proc_manager.erl +++ b/src/couch_proc_manager.erl @@ -233,12 +233,7 @@ terminate(_Reason, #state{tab=Tab}) -> code_change(_OldVsn, {state, Tab}, _Extra) -> State = #state{tab = Tab, threshold_ts = {0,0,0}}, - ProcInts = lists:map( - fun(#proc{} = P) -> - setelement(1, erlang:append_element(P, os:timestamp()), proc_int) - end, - ets:tab2list(Tab) - ), + ProcInts = lists:map(fun import_proc/1, ets:tab2list(Tab)), ets:delete_all_objects(Tab), ets:insert(Tab, ProcInts), {ok, State}. @@ -433,6 +428,11 @@ export_proc(#proc_int{} = ProcInt) -> [_ | Data] = lists:sublist(record_info(size, proc), tuple_to_list(ProcInt)), list_to_tuple([proc | Data]). +import_proc(#proc{} = P) -> + lists:foldl(fun(Idx, ProcInt) -> + setelement(Idx, ProcInt, element(Idx, P)) + end, #proc_int{}, lists:seq(2, tuple_size(P))). + maybe_spawn_proc(State, Client) -> #state{proc_counts=Counts, waiting=Waiting} = State, #client{lang=Lang} = Client,