aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percept/src/percept_db.erl
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-08-24 16:00:01 +0200
committerHenrik Nord <[email protected]>2011-08-24 16:00:13 +0200
commitd5261ddddfba705ed01540f5d60574c02eec67be (patch)
tree0cce44885ece0843796dd437ffffe997f5838f68 /lib/percept/src/percept_db.erl
parentadeecbacf58888df01d11c74f031581e2aab9520 (diff)
parent30bcf83fd22ab4f3ab817beef2380e9cb72ba3d1 (diff)
downloadotp-d5261ddddfba705ed01540f5d60574c02eec67be.tar.gz
otp-d5261ddddfba705ed01540f5d60574c02eec67be.tar.bz2
otp-d5261ddddfba705ed01540f5d60574c02eec67be.zip
Merge branch 'ao/fix-percept-msgs' into dev
* ao/fix-percept-msgs: Fix message handling in select requests Add demonitor to avoid keeping DOWN message in the queue OTP-9490
Diffstat (limited to 'lib/percept/src/percept_db.erl')
-rw-r--r--lib/percept/src/percept_db.erl11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/percept/src/percept_db.erl b/lib/percept/src/percept_db.erl
index 52e9afb78f..61b68ce44f 100644
--- a/lib/percept/src/percept_db.erl
+++ b/lib/percept/src/percept_db.erl
@@ -92,7 +92,7 @@ restart(PerceptDB)->
stop_sync(PerceptDB),
do_start().
-%% @spec do_start(pid()) -> pid()
+%% @spec do_start() -> pid()
%% @private
%% @doc starts the percept database.
@@ -131,6 +131,7 @@ stop_sync(Pid)->
{'DOWN', MonitorRef, _Type, Pid, _Info}->
true
after ?STOP_TIMEOUT->
+ erlang:demonitor(MonitorRef, [flush]),
exit(Pid, kill)
end.
@@ -166,14 +167,14 @@ insert(Trace) ->
select(Query) ->
percept_db ! {select, self(), Query},
- receive Match -> Match end.
+ receive {result, Match} -> Match end.
%% @spec select(atom(), list()) -> Result
%% @equiv select({Table,Options})
select(Table, Options) ->
percept_db ! {select, self(), {Table, Options}},
- receive Match -> Match end.
+ receive {result, Match} -> Match end.
%% @spec consolidate() -> Result
%% @doc Checks timestamp and state-flow inconsistencies in the
@@ -213,7 +214,7 @@ loop_percept_db() ->
insert_trace(clean_trace(Trace)),
loop_percept_db();
{select, Pid, Query} ->
- Pid ! select_query(Query),
+ Pid ! {result, select_query(Query)},
loop_percept_db();
{action, stop} ->
stopped;
@@ -222,7 +223,7 @@ loop_percept_db() ->
loop_percept_db();
{operate, Pid, {Table, {Fun, Start}}} ->
Result = ets:foldl(Fun, Start, Table),
- Pid ! Result,
+ Pid ! {result, Result},
loop_percept_db();
Unhandled ->
io:format("loop_percept_db, unhandled query: ~p~n", [Unhandled]),