From 3f3dae427d54e243a2f1dd3e2bd902388a0f6ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Mon, 3 Jul 2023 14:49:24 +0200 Subject: [PATCH] Fix handling of the undefined host type for stream errors Stream errors are often sent before the host type is known. The 'host_type' in the c2s state is then undefined, not '<<>>'. By fixing this line: - There are no more errors in the logs about running hooks for undefined host type. - The line should be covered by the tests now. --- src/c2s/mongoose_c2s.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c2s/mongoose_c2s.erl b/src/c2s/mongoose_c2s.erl index 4ed2887d10..199505cbf9 100644 --- a/src/c2s/mongoose_c2s.erl +++ b/src/c2s/mongoose_c2s.erl @@ -962,7 +962,7 @@ sm_unset_reason(_) -> %% @doc This is the termination point - from here stanza is sent to the user -spec do_send_element(data(), exml:element(), mongoose_acc:t()) -> mongoose_acc:t(). -do_send_element(StateData = #c2s_data{host_type = <<>>}, El, Acc) -> +do_send_element(StateData = #c2s_data{host_type = undefined}, El, Acc) -> send_xml(StateData, El), Acc; do_send_element(StateData = #c2s_data{host_type = HostType}, #xmlel{} = El, Acc) ->