From 72be948397f73956fc4c2e39fc99f0ec81d92ed0 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Tue, 25 Aug 2009 04:49:39 +0000 Subject: fix a process leak in local changes feed consumer git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@807477 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_rep_changes_feed.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/couchdb') diff --git a/src/couchdb/couch_rep_changes_feed.erl b/src/couchdb/couch_rep_changes_feed.erl index 7ff741e4..da324a0e 100644 --- a/src/couchdb/couch_rep_changes_feed.erl +++ b/src/couchdb/couch_rep_changes_feed.erl @@ -97,7 +97,12 @@ init([_Parent, Source, Since, PostProps]) -> false -> spawn_link(fun() -> send_local_changes_once(Server, Source, Since) end); true -> - spawn_link(fun() -> send_local_changes_forever(Server, Source, Since) end) + spawn_link(fun() -> + Self = self(), + {ok, _} = couch_db_update_notifier:start_link(fun(Msg) -> + local_update_notification(Self, Source#db.name, Msg) end), + send_local_changes_forever(Server, Source, Since) + end) end, {ok, #state{changes_loop=ChangesPid}}. @@ -312,9 +317,6 @@ maybe_stream_next(_) -> send_local_changes_forever(Server, Db, Since) -> #db{name = DbName, user_ctx = UserCtx} = Db, - Self = self(), - {ok, _} = couch_db_update_notifier:start_link( - fun(Msg) -> local_update_notification(Self, DbName, Msg) end), {ok, NewSeq} = send_local_changes_once(Server, Db, Since), couch_db:close(Db), ok = wait_db_updated(), -- cgit v1.2.3