From 4c1b0886f0a2481d23eee13c1475a383800cc1ec Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 6 Aug 2009 13:40:45 +0000 Subject: batch=ok was leaking processes and ignoring intervals. Closes COUCHDB-454 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@801645 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_batch_save.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/couchdb/couch_batch_save.erl') diff --git a/src/couchdb/couch_batch_save.erl b/src/couchdb/couch_batch_save.erl index 38fc8608..600dd00e 100644 --- a/src/couchdb/couch_batch_save.erl +++ b/src/couchdb/couch_batch_save.erl @@ -196,7 +196,9 @@ send_commit(Pid) -> Pid ! {self(), commit}, receive {Pid, committed} -> - ok + ok; + {'DOWN', _, _, Pid, _} -> + exit(normal) end. batch_pid_for_db_and_user(DbName, UserCtx) -> @@ -227,7 +229,11 @@ send_doc_to_batch(Pid, Doc) -> % the loop that holds documents between commits doc_collector(DbName, UserCtx, {BatchSize, BatchInterval}, new) -> % start a process that triggers commit every BatchInterval milliseconds - _IntervalPid = spawn_link(fun() -> commit_every_ms(self(), BatchInterval) end), + Me = self(), + spawn_link(fun() -> + erlang:monitor(process, Me), + commit_every_ms(Me, BatchInterval) + end), doc_collector(DbName, UserCtx, {BatchSize, BatchInterval}, []); doc_collector(DbName, UserCtx, {BatchSize, BatchInterval}, Docs) when length(Docs) >= BatchSize-> -- cgit v1.2.3