summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-08-06 13:40:45 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-08-06 13:40:45 +0000
commit4c1b0886f0a2481d23eee13c1475a383800cc1ec (patch)
tree19767de5c126c82770c709671d4ecf6314d34c42
parent4f464fc5cfae0649a2fbd0aa563a0fb53bb63542 (diff)
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
-rw-r--r--src/couchdb/couch_batch_save.erl10
1 files changed, 8 insertions, 2 deletions
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->