diff options
author | Matthew Sackman <matthew@lshift.net> | 2009-07-09 17:25:40 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@lshift.net> | 2009-07-09 17:25:40 +0100 |
commit | 563dc889dc4fafa2198be63d03793741cb8427d7 (patch) | |
tree | b961e12732a0a82c1463136e37cadc57c569cdbd | |
parent | 3bef2ad2f74e288306061c837d2222d2005dac7c (diff) | |
download | rabbitmq-server-563dc889dc4fafa2198be63d03793741cb8427d7.tar.gz |
...and with some testing and debugging, it might even work as described in the documentation!
-rw-r--r-- | src/gen_server2.erl | 29 | ||||
-rw-r--r-- | src/rabbit_disk_queue.erl | 23 |
2 files changed, 24 insertions, 28 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl index c19f1601..253c2eb1 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -477,11 +477,11 @@ loop(Parent, Name, State, Mod, Time, TimeoutState, MinPri, Queue, Debug) -> Time, TimeoutState, MinPri, in(Input, Queue), Debug) after 0 -> process_next_msg(Parent, Name, State, Mod, Time, TimeoutState, - MinPri, Queue, Debug, false) + MinPri, Queue, Debug) end. process_next_msg(Parent, Name, State, Mod, Time, TimeoutState, MinPri, Queue, - Debug, Hib) -> + Debug) -> Res = case MinPri of any -> priority_queue:out(Queue); _ -> priority_queue:out(MinPri, Queue) @@ -489,11 +489,11 @@ process_next_msg(Parent, Name, State, Mod, Time, TimeoutState, MinPri, Queue, case Res of {{value, Msg}, Queue1} -> process_msg(Parent, Name, State, Mod, - Time, TimeoutState, Queue1, Debug, Hib, Msg); + Time, TimeoutState, Queue1, Debug, Msg); {empty, Queue1} -> - Time1 = case {Hib, Time, TimeoutState} of - {true, _, _} -> 0; - {_, binary, {Current, _Min, undefined}} -> Current; + Time1 = case {Time, TimeoutState} of + {hibernate, _} -> 0; + {binary, {Current, _Min, undefined}} -> Current; _ -> Time end, receive @@ -502,11 +502,11 @@ process_next_msg(Parent, Name, State, Mod, Time, TimeoutState, MinPri, Queue, Time, TimeoutState, MinPri, in(Input, Queue1), Debug) after Time1 -> process_msg(Parent, Name, State, Mod, - Time, TimeoutState, Queue1, Debug, Hib, - case Hib of - true -> roused_and_disinterested; - false -> timeout - end) + Time, TimeoutState, Queue1, Debug, + case Time == hibernate of + true -> roused_and_disinterested; + false -> timeout + end) end end. @@ -517,7 +517,7 @@ wake_hib(Parent, Name, State, Mod, TimeoutState, MinPri, Queue, Debug) -> end, TimeoutState1 = adjust_hibernate_after(TimeoutState), process_next_msg(Parent, Name, State, Mod, hibernate, TimeoutState1, - MinPri, in(Msg, Queue), Debug, true). + MinPri, in(Msg, Queue), Debug). adjust_hibernate_after(undefined) -> undefined; @@ -548,15 +548,12 @@ in(Input, Queue) -> priority_queue:in(Input, Queue). process_msg(Parent, Name, State, Mod, Time, TimeoutState, Queue, - Debug, _Hib, Msg) -> + Debug, Msg) -> case Msg of {system, From, Req} -> sys:handle_system_msg (Req, From, Parent, ?MODULE, Debug, [Name, State, Mod, Time, TimeoutState, Queue]); - %% gen_server puts Hib on the end as the 7th arg, but that - %% version of the function seems not to be documented so - %% leaving out for now. {'EXIT', Parent, Reason} -> terminate(Reason, Name, Msg, Mod, State, Debug); _Msg when Debug =:= [] -> diff --git a/src/rabbit_disk_queue.erl b/src/rabbit_disk_queue.erl index a537e456..eaeef9e3 100644 --- a/src/rabbit_disk_queue.erl +++ b/src/rabbit_disk_queue.erl @@ -433,7 +433,7 @@ init([FileSizeLimit, ReadFileHandlesLimit]) -> {ok, case Mode of mixed -> State2; disk -> to_disk_only_mode(State2) - end, {binary, ?HIBERNATE_AFTER_MIN}}. + end, {binary, ?HIBERNATE_AFTER_MIN}, 0}. handle_call({deliver, Q}, _From, State) -> {ok, Result, State1} = internal_deliver(Q, true, false, State), @@ -517,10 +517,9 @@ handle_info({'EXIT', _Pid, Reason}, State) -> handle_info(timeout, State = #dqstate { commit_timer_ref = undefined }) -> ok = report_memory(true, State), %% don't use noreply/1 or noreply1/1 as they'll restart the memory timer - {noreply, stop_memory_timer(State), hibernate}; + {noreply, stop_memory_timer(State), hibernate, 0}; handle_info(timeout, State) -> - noreply(sync_current_file_handle(State)); -handle_info(_Info, State) -> + noreply(sync_current_file_handle(State)). noreply(State). terminate(_Reason, State) -> @@ -647,26 +646,26 @@ noreply(NewState) -> noreply1(NewState = #dqstate { on_sync_froms = [], commit_timer_ref = undefined }) -> - {noreply, NewState, binary}; + {noreply, NewState, binary, 0}; noreply1(NewState = #dqstate { commit_timer_ref = undefined }) -> - {noreply, start_commit_timer(NewState), 0}; + {noreply, start_commit_timer(NewState), 0, 0}; noreply1(NewState = #dqstate { on_sync_froms = [] }) -> - {noreply, stop_commit_timer(NewState), binary}; + {noreply, stop_commit_timer(NewState), binary, 0}; noreply1(NewState) -> - {noreply, NewState, 0}. + {noreply, NewState, 0, 0}. reply(Reply, NewState) -> reply1(Reply, start_memory_timer(NewState)). reply1(Reply, NewState = #dqstate { on_sync_froms = [], commit_timer_ref = undefined }) -> - {reply, Reply, NewState, binary}; + {reply, Reply, NewState, binary, 0}; reply1(Reply, NewState = #dqstate { commit_timer_ref = undefined }) -> - {reply, Reply, start_commit_timer(NewState), 0}; + {reply, Reply, start_commit_timer(NewState), 0, 0}; reply1(Reply, NewState = #dqstate { on_sync_froms = [] }) -> - {reply, Reply, stop_commit_timer(NewState), binary}; + {reply, Reply, stop_commit_timer(NewState), binary, 0}; reply1(Reply, NewState) -> - {reply, Reply, NewState, 0}. + {reply, Reply, NewState, 0, 0}. form_filename(Name) -> filename:join(base_directory(), Name). |