diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2010-10-19 11:38:51 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-10-19 11:38:51 +0100 |
commit | 533a582c18a3bce45f6a2f696fe56cd6deb8dc0d (patch) | |
tree | 18841b3780f8b333283f06566c3ff911314a5ead | |
parent | e702da007f2bb77f229509395fa6061352401704 (diff) | |
download | rabbitmq-server-533a582c18a3bce45f6a2f696fe56cd6deb8dc0d.tar.gz |
Refactoring
-rw-r--r-- | src/rabbit_msg_store_gc.erl | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/rabbit_msg_store_gc.erl b/src/rabbit_msg_store_gc.erl index a3a9dcd1..8bd515e3 100644 --- a/src/rabbit_msg_store_gc.erl +++ b/src/rabbit_msg_store_gc.erl @@ -131,25 +131,24 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}. attempt_action(Action, Files, - State = #state { pending_no_readers = Pending, + State = #state { parent = Parent, + pending_no_readers = Pending, msg_store_state = MsgStoreState }) -> case lists:filter(fun (File) -> rabbit_msg_store:has_readers(File, MsgStoreState) end, Files) of - [] -> do_action(Action, Files, State); - [File | _] -> State #state { - pending_no_readers = - dict:store(File, {Action, Files}, Pending) } + [] -> + {Reclaimed, Casualty, Survivor} = + do_action(Action, Files, MsgStoreState), + ok = rabbit_msg_store:gc_done(Parent, Reclaimed, Casualty, + Survivor), + State; + [File | _] -> + State #state { + pending_no_readers = dict:store(File, {Action, Files}, Pending) } end. -do_action(combine, [Source, Destination], - State = #state { parent = Parent, - msg_store_state = MsgStoreState }) -> - Reclaimed = rabbit_msg_store:combine(Source, Destination, MsgStoreState), - ok = rabbit_msg_store:gc_done(Parent, Reclaimed, Source, Destination), - State; -do_action(delete, [File], State = #state { parent = Parent, - msg_store_state = MsgStoreState }) -> - FileSize = rabbit_msg_store:delete_file(File, MsgStoreState), - ok = rabbit_msg_store:gc_done(Parent, FileSize, File, undefined), - State. +do_action(combine, [Source, Destination], MsgStoreState) -> + {rabbit_msg_store:combine(Source, Destination, MsgStoreState), Source, Destination}; +do_action(delete, [File], MsgStoreState) -> + {rabbit_msg_store:delete_file(File, MsgStoreState), File, undefined}. |