Don't crash for clients without a last will

References #74
This commit is contained in:
Arnaud Cogoluègnes 2016-12-07 11:21:47 +01:00
parent b3f2bcfaed
commit 88820d02d9
1 changed files with 5 additions and 1 deletions

View File

@ -601,12 +601,16 @@ ensure_queue(Qos, #proc_state{ channels = {Channel, _},
{Q, PState}
end.
send_will(PState = #proc_state{will_msg = undefined}) ->
PState;
send_will(PState = #proc_state{will_msg = WillMsg = #mqtt_msg{retain = Retain, topic = Topic}, retainer_pid = RPid}) ->
amqp_pub(WillMsg, PState),
case Retain of
false -> ok;
true -> hand_off_to_retainer(RPid, Topic, WillMsg)
end.
end,
PState.
amqp_pub(undefined, PState) ->
PState;