diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-10-04 12:36:13 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-10-04 12:36:13 +0100 |
| commit | 68948e96b5073ac6291c837070f942433770a07f (patch) | |
| tree | 5036cc5577d47075ff0397051ce8bc45bb8689d9 | |
| parent | 290ac1e2bba29a156ad7bfcbd5c781f0c822b122 (diff) | |
| download | rabbitmq-server-git-68948e96b5073ac6291c837070f942433770a07f.tar.gz | |
schedule a fsync if necessary before confirming messages
| -rw-r--r-- | src/rabbit_msg_store.erl | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 0dba4dd27d..521c1c0939 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -846,15 +846,21 @@ internal_sync(State = #msstate { current_file_handle = CurHdl, client_ondisk_callback = CODC, cref_to_guids = CTG }) -> State1 = stop_sync_timer(State), + CGs = dict:fold(fun (_CRef, [], NS) -> NS; + (CRef, Guids, NS) -> [{CRef, Guids} | NS] + end, [], CTG), + if Syncs =/= [] orelse CGs =/= [] -> ok = file_handle_cache:sync(CurHdl); + true -> ok + end, State2 = case Syncs of [] -> State1; - _ -> ok = file_handle_cache:sync(CurHdl), - lists:foreach(fun (K) -> K() end, lists:reverse(Syncs)), + _ -> lists:foreach(fun (K) -> K() end, lists:reverse(Syncs)), State1 #msstate { on_sync = [] } end, - dict:map(fun(CRef, Guids) -> Fun = dict:fetch(CRef, CODC), - Fun(Guids) - end, CTG), + [begin + Fun = dict:fetch(CRef, CODC), + Fun(Guids) + end || {CRef, Guids} <- CGs], State2 #msstate { cref_to_guids = dict:new() }. |
