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 5D8EB10FEC for ; Tue, 5 Aug 2014 11:06:03 +0000 (UTC) Received: (qmail 17349 invoked by uid 500); 5 Aug 2014 11:06:02 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 17210 invoked by uid 500); 5 Aug 2014 11:06:02 -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 16953 invoked by uid 99); 5 Aug 2014 11:06:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 11:06:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 308139BF56E; Tue, 5 Aug 2014 11:06:02 +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: Tue, 05 Aug 2014 11:06:09 -0000 Message-Id: In-Reply-To: <79808409c930470cad8b558b6c4f8df3@git.apache.org> References: <79808409c930470cad8b558b6c4f8df3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/21] couch commit: updated refs/heads/windsor-merge-119 to 9138d07 Update couch_changes to use new couch_event app Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/c24e6d68 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/c24e6d68 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/c24e6d68 Branch: refs/heads/windsor-merge-119 Commit: c24e6d6805d638879832fcf338bb42f2f201d104 Parents: be7b1a4 Author: Paul J. Davis Authored: Tue Apr 23 16:00:01 2013 -0500 Committer: Robert Newson Committed: Mon Aug 4 15:19:30 2014 +0100 ---------------------------------------------------------------------- src/couch_changes.erl | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c24e6d68/src/couch_changes.erl ---------------------------------------------------------------------- diff --git a/src/couch_changes.erl b/src/couch_changes.erl index fd14f3d..637a6ba 100644 --- a/src/couch_changes.erl +++ b/src/couch_changes.erl @@ -19,7 +19,8 @@ wait_db_updated/3, get_rest_db_updated/1, configure_filter/4, - filter/3 + filter/3, + handle_db_event/3 ]). -export([changes_enumerator/2]). @@ -77,13 +78,8 @@ handle_changes(Args1, Req, Db0) -> true -> fun(CallbackAcc) -> {Callback, UserAcc} = get_callback_acc(CallbackAcc), - Self = self(), - {ok, Notify} = couch_db_update_notifier:start_link( - fun({updated, DbName}) when Db0#db.name == DbName -> - Self ! db_updated; - (_) -> - ok - end + {ok, Listener} = couch_event:link_listener( + ?MODULE, handle_db_event, self(), [{dbname, Db0#db.name}] ), {Db, StartSeq} = Start(), UserAcc2 = start_sending_changes(Callback, UserAcc, Feed), @@ -96,7 +92,7 @@ handle_changes(Args1, Req, Db0) -> Acc0, true) after - couch_db_update_notifier:stop(Notify), + couch_event:stop_listener(Listener), get_rest_db_updated(ok) % clean out any remaining update messages end end; @@ -117,6 +113,15 @@ handle_changes(Args1, Req, Db0) -> end end. + +handle_db_event(_DbName, updated, Parent) -> + Parent ! db_updated, + {ok, Parent}; + +handle_db_event(_DbName, _Event, Parent) -> + {ok, Parent}. + + get_callback_acc({Callback, _UserAcc} = Pair) when is_function(Callback, 3) -> Pair; get_callback_acc(Callback) when is_function(Callback, 2) ->