summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2010-06-12 18:41:44 +0000
committerAdam Kocoloski <kocolosk@apache.org>2010-06-12 18:41:44 +0000
commitd8ac0bba6b98cf22d6a8860ea7ad01de001971c5 (patch)
treeca62508e37ff25f6a56211a423a051d094a82fc7
parentc71b9fa6a197db1657aac41f8fd2994f23364d3b (diff)
remove unnuecessary receive loop in commit_data. COUCHDB-794
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@954043 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/couchdb/couch_db_updater.erl34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index a8ffc6cc..664b1e97 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -215,6 +215,9 @@ handle_info({update_docs, Client, GroupedDocs, NonRepDocs, MergeConflicts,
[catch(ClientPid ! {retry, self()}) || ClientPid <- Clients],
{noreply, Db}
end;
+handle_info(delayed_commit, #db{waiting_delayed_commit=nil}=Db) ->
+ %no outstanding delayed commits, ignore
+ {noreply, Db};
handle_info(delayed_commit, Db) ->
case commit_data(Db) of
Db ->
@@ -671,23 +674,22 @@ db_to_header(Db, Header) ->
security_ptr = Db#db.security_ptr,
revs_limit = Db#db.revs_limit}.
-commit_data(#db{fd=Fd,header=OldHeader,fsync_options=FsyncOptions}=Db, Delay) ->
- Header = db_to_header(Db, OldHeader),
- if OldHeader == Header ->
- Db;
- Delay and (Db#db.waiting_delayed_commit == nil) ->
- Db#db{waiting_delayed_commit=
- erlang:send_after(1000, self(), delayed_commit)};
- Delay ->
+commit_data(#db{waiting_delayed_commit=nil} = Db, true) ->
+ Db#db{waiting_delayed_commit=erlang:send_after(1000,self(),delayed_commit)};
+commit_data(Db, true) ->
+ Db;
+commit_data(Db, _) ->
+ #db{
+ fd = Fd,
+ header = OldHeader,
+ fsync_options = FsyncOptions,
+ waiting_delayed_commit = Timer
+ } = Db,
+ if is_reference(Timer) -> erlang:cancel_timer(Timer); true -> ok end,
+ case db_to_header(Db, OldHeader) of
+ OldHeader ->
Db;
- true ->
- if Db#db.waiting_delayed_commit /= nil ->
- case erlang:cancel_timer(Db#db.waiting_delayed_commit) of
- false -> receive delayed_commit -> ok after 0 -> ok end;
- _ -> ok
- end;
- true -> ok
- end,
+ Header ->
case lists:member(before_header, FsyncOptions) of
true -> ok = couch_file:sync(Fd);
_ -> ok