Skip to content

Commit 82cd452

Browse files
committed
Make mnesia:wait_for_tables/2 contain internal message in temp process
1 parent 412bff5 commit 82cd452

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lib/mnesia/src/mnesia_controller.erl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,28 @@ wait_for_tables(Tabs, Timeout) ->
232232
do_wait_for_tables(Tabs, 0) ->
233233
reply_wait(Tabs);
234234
do_wait_for_tables(Tabs, Timeout) ->
235-
Pid = spawn_link(?MODULE, wait_for_tables_init, [self(), Tabs]),
235+
Parent = self(),
236+
Fun = fun() ->
237+
PidInner = spawn_link(?MODULE, wait_for_tables_init, [self(), Tabs]),
238+
receive
239+
{?SERVER_NAME, PidInner, Res} ->
240+
Parent ! {?SERVER_NAME, self(), Res},
241+
unlink(Parent)
242+
after Timeout ->
243+
unlink(PidInner),
244+
exit(PidInner, timeout),
245+
Parent ! {?SERVER_NAME, self(), timeout},
246+
unlink(Parent)
247+
end
248+
end,
249+
PidOuter = spawn_link(Fun),
236250
receive
237-
{?SERVER_NAME, Pid, Res} ->
238-
Res;
239-
{'EXIT', Pid, _} ->
240-
reply_wait(Tabs)
241-
after Timeout ->
242-
unlink(Pid),
243-
exit(Pid, timeout),
244-
reply_wait(Tabs)
251+
{?SERVER_NAME, PidOuter, timeout} ->
252+
reply_wait(Tabs);
253+
{?SERVER_NAME, PidOuter, Res} ->
254+
Res;
255+
{'EXIT', PidOuter, _} ->
256+
reply_wait(Tabs)
245257
end.
246258

247259
reply_wait(Tabs) ->

0 commit comments

Comments
 (0)