{"action":"closed","issue":{"url":"https://api.github.com/repos/processone/ejabberd/issues/63","labels_url":"https://api.github.com/repos/processone/ejabberd/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/processone/ejabberd/issues/63/comments","events_url":"https://api.github.com/repos/processone/ejabberd/issues/63/events","html_url":"https://github.com/processone/ejabberd/issues/63","id":13438433,"number":63,"title":"ejabberd_sm: {broadcast messages are not handled","user":{"login":"mgpld","id":1147613,"avatar_url":"https://avatars.githubusercontent.com/u/1147613?v=3","gravatar_id":"","url":"https://api.github.com/users/mgpld","html_url":"https://github.com/mgpld","followers_url":"https://api.github.com/users/mgpld/followers","following_url":"https://api.github.com/users/mgpld/following{/other_user}","gists_url":"https://api.github.com/users/mgpld/gists{/gist_id}","starred_url":"https://api.github.com/users/mgpld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgpld/subscriptions","organizations_url":"https://api.github.com/users/mgpld/orgs","repos_url":"https://api.github.com/users/mgpld/repos","events_url":"https://api.github.com/users/mgpld/events{/privacy}","received_events_url":"https://api.github.com/users/mgpld/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/processone/ejabberd/labels/Component:Core","name":"Component:Core","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"badlop","id":96807,"avatar_url":"https://avatars.githubusercontent.com/u/96807?v=3","gravatar_id":"","url":"https://api.github.com/users/badlop","html_url":"https://github.com/badlop","followers_url":"https://api.github.com/users/badlop/followers","following_url":"https://api.github.com/users/badlop/following{/other_user}","gists_url":"https://api.github.com/users/badlop/gists{/gist_id}","starred_url":"https://api.github.com/users/badlop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/badlop/subscriptions","organizations_url":"https://api.github.com/users/badlop/orgs","repos_url":"https://api.github.com/users/badlop/repos","events_url":"https://api.github.com/users/badlop/events{/privacy}","received_events_url":"https://api.github.com/users/badlop/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2013-04-20T17:15:51Z","updated_at":"2015-02-22T12:24:48Z","closed_at":"2015-02-22T12:24:48Z","body":"Ejabberd sm fails with:\r\n\r\n```erlang\r\n=ERROR REPORT==== 2013-04-20 12:14:19 ===\r\nE(<0.293.0>:ejabberd_sm:104) : {{badmatch,\r\n                                 {broadcast,\r\n                                  {item,\r\n                                   {<<\"a\">>,<<\"h@dev.com\">>,<<>>},\r\n                                   none}}},\r\n                                [{ejabberd_sm,do_route,3,\r\n                                  [{file,\"ejabberd_sm.erl\"},{line,463}]},\r\n                                 {ejabberd_sm,route,3,\r\n                                  [{file,\"ejabberd_sm.erl\"},{line,102}]},\r\n                                 {mod_roster,push_item,4,\r\n                                  [{file,\"mod_roster.erl\"},{line,551}]},\r\n                                 {mod_roster,process_item_set,3,\r\n                                  [{file,\"mod_roster.erl\"},{line,493}]},\r\n                                 {lists,foreach,2,\r\n                                  [{file,\"lists.erl\"},{line,1313}]},\r\n                                 {mod_roster,process_iq_set,3,\r\n                                  [{file,\"mod_roster.erl\"},{line,459}]},\r\n                                 {gen_iq_handler,process_iq,6,\r\n                                  [{file,\"gen_iq_handler.erl\"},{line,114}]},\r\n                                 {gen_iq_handler,handle_info,2,\r\n                                  [{file,\"gen_iq_handler.erl\"},{line,169}]}]}\r\nwhen processing: {{jid,<<>>,<<>>,<<>>,<<>>,<<>>,<<>>},\r\n                  {jid,<<\"test\">>,<<\"h@dev.com\">>,<<>>,<<\"test\">>,\r\n                       <<\"h@dev.com\">>,<<>>},\r\n                  {broadcast,{item,{<<\"a\">>,<<\"h@dev.com\">>,<<>>},\r\n                                   none}}}\r\n```\r\n\r\nThe fix is easy: \r\n```diff\r\n--- a/src/ejabberd_sm.erl\r\n+++ b/src/ejabberd_sm.erl\r\n@@ -454,6 +454,8 @@ recount_session_table(Node) ->\r\n \r\n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n \r\n+do_route(From, To, {broadcast, _} = Packet) ->\r\n+    route_message(From, To, Packet);\r\n do_route(From, To, Packet) ->\r\n     ?DEBUG(\"session manager~n\\tfrom ~p~n\\tto ~p~n\\tpacket \"\r\n           \"~P~n\",\r\n```"}}