Author: kocolosk
Date: Thu Aug 6 13:40:45 2009
New Revision: 801645
URL: http://svn.apache.org/viewvc?rev=801645&view=rev
Log:
batch=ok was leaking processes and ignoring intervals. Closes COUCHDB-454
Modified:
couchdb/trunk/src/couchdb/couch_batch_save.erl
Modified: couchdb/trunk/src/couchdb/couch_batch_save.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_batch_save.erl?rev=801645&r1=801644&r2=801645&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_batch_save.erl (original)
+++ couchdb/trunk/src/couchdb/couch_batch_save.erl Thu Aug 6 13:40:45 2009
@@ -196,7 +196,9 @@
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 @@
% 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->
|