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 159F917D57 for ; Sat, 4 Apr 2015 23:29:02 +0000 (UTC) Received: (qmail 46735 invoked by uid 500); 4 Apr 2015 23:28:58 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 46623 invoked by uid 500); 4 Apr 2015 23:28:58 -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 44474 invoked by uid 99); 4 Apr 2015 23:28:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Apr 2015 23:28:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 83DAAE2F79; Sat, 4 Apr 2015 23:28:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kxepal@apache.org To: commits@couchdb.apache.org Date: Sat, 04 Apr 2015 23:29:27 -0000 Message-Id: In-Reply-To: <7e6f3f454a6141008e620dd6cb309fa6@git.apache.org> References: <7e6f3f454a6141008e620dd6cb309fa6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [32/48] couch commit: updated refs/heads/master to 7776921 Assign waiter on return_proc in couch_proc_manager There is a case when we return_proc while waiters exist. We should assign returned proc to one of them. Effectively we unfreeze the waiter. COUCHDB-2547 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/80f8330a Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/80f8330a Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/80f8330a Branch: refs/heads/master Commit: 80f8330a8dd99c29f0bcc8d2d776ee04a54815b9 Parents: b59a4b2 Author: ILYA Khlopotov Authored: Wed Feb 4 13:25:45 2015 -0800 Committer: ILYA Khlopotov Committed: Tue Feb 10 11:06:44 2015 -0800 ---------------------------------------------------------------------- src/couch_proc_manager.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/80f8330a/src/couch_proc_manager.erl ---------------------------------------------------------------------- diff --git a/src/couch_proc_manager.erl b/src/couch_proc_manager.erl index f0fc6fa..20514cc 100644 --- a/src/couch_proc_manager.erl +++ b/src/couch_proc_manager.erl @@ -449,13 +449,23 @@ return_proc(#state{} = State, #proc_int{} = ProcInt) -> true = ets:update_element(?PROCS, Pid, [ {#proc_int.client, undefined} ]), - State + maybe_assign_proc(State, ProcInt) end; false -> remove_proc(State, ProcInt) end, flush_waiters(NewState, Lang). +maybe_assign_proc(#state{} = State, ProcInt) -> + #proc_int{pid = Pid, lang = Lang} = ProcInt, + case get_waiting_client(Lang) of + #client{from = From} = Client -> + Proc = assign_proc(Client, ProcInt#proc_int{client=undefined}), + gen_server:reply(From, {ok, Proc, State#state.config}), + State; + undefined -> + State + end. remove_proc(State, #proc_int{}=Proc) -> ets:delete(?PROCS, Proc#proc_int.pid),