fix wildcard topics match

This commit is contained in:
Feng Lee 2015-01-08 14:40:05 +08:00
parent 4a2b586ff9
commit 5ed1217b0a
3 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,13 @@
eMQTT ChangeLog eMQTT ChangeLog
================== ==================
0.2.1 (2015-01-08)
-------------------
pull request 26: Use binaries for topic paths and fix wildcard topics
emqtt_pubsub.erl: fix wildcard topic match bug caused by binary topic in 0.2.0
0.2.0 (2014-12-07) 0.2.0 (2014-12-07)
------------------- -------------------

6
TODO
View File

@ -1,3 +1,9 @@
0.2.2
=====
merge pull request#26
0.2.0 0.2.0
===== =====

View File

@ -249,10 +249,10 @@ trie_match(NodeId, [W|Words], ResAcc) ->
[#topic_trie{node_id=ChildId}] -> trie_match(ChildId, Words, Acc); [#topic_trie{node_id=ChildId}] -> trie_match(ChildId, Words, Acc);
[] -> Acc [] -> Acc
end end
end, 'trie_match_#'(NodeId, ResAcc), [W, "+"]). end, 'trie_match_#'(NodeId, ResAcc), [W, <<"+">>]).
'trie_match_#'(NodeId, ResAcc) -> 'trie_match_#'(NodeId, ResAcc) ->
case mnesia:read(topic_trie, #topic_trie_edge{node_id=NodeId, word="#"}) of case mnesia:read(topic_trie, #topic_trie_edge{node_id=NodeId, word = <<"#">>}) of
[#topic_trie{node_id=ChildId}] -> [#topic_trie{node_id=ChildId}] ->
mnesia:read(topic_trie_node, ChildId) ++ ResAcc; mnesia:read(topic_trie_node, ChildId) ++ ResAcc;
[] -> [] ->