diff options
| author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-02-22 12:39:28 +0000 |
|---|---|---|
| committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-02-22 12:39:28 +0000 |
| commit | 65d7a0d4bce7c53f03c9c51ee6c202f0313d2b75 (patch) | |
| tree | e2c7464a652f2aa5dd1c41a75242a315e4af3ed3 /src | |
| parent | 06f5ec199e9314aa1de26c4d673e53699c4a3549 (diff) | |
| download | rabbitmq-server-git-65d7a0d4bce7c53f03c9c51ee6c202f0313d2b75.tar.gz | |
Removed sync_if/2 and sync/2.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_queue_index.erl | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 366e1b1be1..1e55add215 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -18,7 +18,7 @@ -export([init/2, shutdown_terms/1, recover/5, terminate/2, delete_and_terminate/1, - publish/5, deliver/2, ack/2, sync/1, sync/2, needs_sync/1, flush/1, + publish/5, deliver/2, ack/2, sync/1, needs_sync/1, flush/1, read/3, next_segment_boundary/1, bounds/1, recover/1]). -export([add_queue_ttl/0]). @@ -207,7 +207,7 @@ -> qistate()). -spec(deliver/2 :: ([seq_id()], qistate()) -> qistate()). -spec(ack/2 :: ([seq_id()], qistate()) -> qistate()). --spec(sync/2 :: ([seq_id()], qistate()) -> qistate()). +-spec(sync/1 :: (qistate()) -> qistate()). -spec(flush/1 :: (qistate()) -> qistate()). -spec(read/3 :: (seq_id(), seq_id(), qistate()) -> {[{rabbit_types:msg_id(), seq_id(), @@ -285,18 +285,11 @@ ack(SeqIds, State) -> %% This is only called when there are outstanding confirms and the %% queue is idle. -sync(State) -> - sync_if(true, State). - -sync(SeqIds, State) -> - %% The SeqIds here contains the SeqId of every publish and ack to - %% be sync'ed. Ideally we should go through these seqids and only - %% sync the journal if the pubs or acks appear in the - %% journal. However, this would be complex to do, and given that - %% the variable queue publishes and acks to the qi, and then - %% syncs, all in one operation, there is no possibility of the - %% seqids not being in the journal. - sync_if([] =/= SeqIds, State). +sync(State = #qistate { journal_handle = undefined }) -> + State; +sync(State = #qistate { journal_handle = JournalHdl }) -> + ok = file_handle_cache:sync(JournalHdl), + notify_sync(State). needs_sync(#qistate { journal_handle = undefined }) -> false; @@ -712,14 +705,6 @@ deliver_or_ack(Kind, SeqIds, State) -> add_to_journal(SeqId, Kind, StateN) end, State1, SeqIds)). -sync_if(false, State) -> - State; -sync_if(_Bool, State = #qistate { journal_handle = undefined }) -> - State; -sync_if(true, State = #qistate { journal_handle = JournalHdl }) -> - ok = file_handle_cache:sync(JournalHdl), - notify_sync(State). - notify_sync(State = #qistate { unsynced_msg_ids = UG, on_sync = OnSyncFun }) -> OnSyncFun(UG), State #qistate { unsynced_msg_ids = gb_sets:new() }. |
