aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmed Omar <[email protected]>2011-06-06 10:37:48 +0200
committerHenrik Nord <[email protected]>2011-08-24 15:58:11 +0200
commit30bcf83fd22ab4f3ab817beef2380e9cb72ba3d1 (patch)
tree45731dc0e58efa52ccc0888ac2c1a8414cdfb245 /lib
parentc52f5a6220534b9ebd153d5520bc6a01006d7749 (diff)
downloadotp-30bcf83fd22ab4f3ab817beef2380e9cb72ba3d1.tar.gz
otp-30bcf83fd22ab4f3ab817beef2380e9cb72ba3d1.tar.bz2
otp-30bcf83fd22ab4f3ab817beef2380e9cb72ba3d1.zip
Fix message handling in select requests
percept_db used to send results in untagged messages, and use a non selective receive to extract them. When percept is used from the shell process, this can confuse other messages with the actual result. Add a tag to the message to be {result, Result}.
Diffstat (limited to 'lib')
-rw-r--r--lib/percept/src/percept_db.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/percept/src/percept_db.erl b/lib/percept/src/percept_db.erl
index e827b5345c..61b68ce44f 100644
--- a/lib/percept/src/percept_db.erl
+++ b/lib/percept/src/percept_db.erl
@@ -167,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
@@ -214,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;
@@ -223,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]),