From 850218c2df808d9802d960f09c513896b6b06560 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 21 Feb 2011 16:13:41 +0100 Subject: =?UTF-8?q?Forward=20old=20messages=20to=20newly=20spawned=20extau?= =?UTF-8?q?th=20process=20(thanks=20to=20Mika=20Sepp=C3=A4nen)(EJAB-1385)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extauth.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extauth.erl b/src/extauth.erl index c1721a0e..3b2e7db6 100644 --- a/src/extauth.erl +++ b/src/extauth.erl @@ -126,7 +126,8 @@ loop(Port, Timeout, ProcessName, ExtPrg) -> ?ERROR_MSG("extauth call '~p' didn't receive response", [Msg]), Caller ! {eauth, false}, unregister(ProcessName), - spawn(?MODULE, init, [ProcessName, ExtPrg]), + Pid = spawn(?MODULE, init, [ProcessName, ExtPrg]), + flush_buffer_and_forward_messages(Pid), exit(port_terminated) end; stop -> @@ -140,6 +141,15 @@ loop(Port, Timeout, ProcessName, ExtPrg) -> exit(port_terminated) end. +flush_buffer_and_forward_messages(Pid) -> + receive + Message -> + Pid ! Message, + flush_buffer_and_forward_messages(Pid) + after 0 -> + true + end. + join(List, Sep) -> lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ A -- cgit v1.2.3