From 7647fc1631d3f35cfd20e4dd618c351589810c37 Mon Sep 17 00:00:00 2001 From: karmanyaahm Date: Tue, 14 Sep 2021 08:09:03 +0200 Subject: [PATCH] fix deadlock on distributor register (#7) Closes #6 I'm not sure if this is the correct solution according to the library, but it *is* one that works. Co-authored-by: Karmanyaah Malhotra Reviewed-on: https://dev.sum7.eu/genofire/unified-push-xmpp/pulls/7 Co-authored-by: karmanyaahm Co-committed-by: karmanyaahm --- distributor/xmpp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/distributor/xmpp.go b/distributor/xmpp.go index f07e9a2..5c8547c 100644 --- a/distributor/xmpp.go +++ b/distributor/xmpp.go @@ -128,6 +128,10 @@ func (s *XMPPService) Register(appName, token string) (string, string, error) { logger.Errorf("xmpp recv IQ for register: %v", err) return "", "xmpp unable recv iq to gateway", err } + if err := t.Close(); err != nil { + logger.Errorf("unable to close registration response %v", err) + return "", "xmpp unable recv iq to gateway", err + } if endpoint := iqRegister.Register.Endpoint; endpoint != nil { logger.WithField("endpoint", endpoint.Body).Info("success") return endpoint.Body, "", nil