diff options
author | Matthias Radestock <matthias@lshift.net> | 2008-10-16 06:11:33 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2008-10-16 06:11:33 +0100 |
commit | 8f25f029db6fe8a2d498db4c91295f8a0aa8e78f (patch) | |
tree | 89a83226ebd7aaaaab8b9216a73143204e126312 | |
parent | ba42dc1a68bf72d8bac6ee5cd46d2855c10fb2fc (diff) | |
download | rabbitmq-server-bug19552.tar.gz |
fix 'duplicate_next' error when sending messages directly to proxied processbug19552
The buffering_proxy:mainloop was unconditionally requesting new
messages from the proxy. It should only do that when it has just
finished handling the messages given to it by the proxy in response to
a previous request, and not after handling a direct message.
-rw-r--r-- | src/buffering_proxy.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/buffering_proxy.erl b/src/buffering_proxy.erl index d2505701..dc168608 100644 --- a/src/buffering_proxy.erl +++ b/src/buffering_proxy.erl @@ -40,7 +40,8 @@ start_link(M, A) -> ProxyPid = self(), Ref = make_ref(), Pid = spawn_link( - fun () -> mainloop(ProxyPid, Ref, M, + fun () -> ProxyPid ! Ref, + mainloop(ProxyPid, Ref, M, M:init(ProxyPid, A)) end), proxy_loop(Ref, Pid, empty) end). @@ -48,13 +49,15 @@ start_link(M, A) -> %%---------------------------------------------------------------------------- mainloop(ProxyPid, Ref, M, State) -> - ProxyPid ! Ref, NewState = receive {Ref, Messages} -> - lists:foldl(fun (Msg, S) -> - drain(M, M:handle_message(Msg, S)) - end, State, lists:reverse(Messages)); + NewSt = + lists:foldl(fun (Msg, S) -> + drain(M, M:handle_message(Msg, S)) + end, State, lists:reverse(Messages)), + ProxyPid ! Ref, + NewSt; Msg -> M:handle_message(Msg, State) end, ?MODULE:mainloop(ProxyPid, Ref, M, NewState). |