From 77d3f7bb4021f05cbbd5495bad31a924cae37411 Mon Sep 17 00:00:00 2001 From: Nonoo Date: Mon, 19 Oct 2020 09:53:49 +0200 Subject: [PATCH] Modify exit logging --- main.go | 10 +++------- streamcommon.go | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index a80f973..f6a7c26 100644 --- a/main.go +++ b/main.go @@ -17,15 +17,11 @@ func exit(err error) { if err != nil { log.Error(err.Error()) } - log.Print("disconnecting") - if streams.audio.common.conn != nil { - streams.audio.sendDisconnect() - } - if streams.control.common.conn != nil { - streams.control.sendDisconnect() - } + streams.audio.sendDisconnect() + streams.control.sendDisconnect() + log.Print("exiting") if err == nil { os.Exit(0) } else { diff --git a/streamcommon.go b/streamcommon.go index cdeeb13..e15d47e 100644 --- a/streamcommon.go +++ b/streamcommon.go @@ -170,10 +170,11 @@ func (s *streamCommon) waitForPkt6Answer() { } func (s *streamCommon) sendDisconnect() { - if !s.gotRemoteSID { + if !s.gotRemoteSID || s.conn == nil { return } + log.Print(s.name + "/disconnecting") s.send([]byte{0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, byte(s.localSID >> 24), byte(s.localSID >> 16), byte(s.localSID >> 8), byte(s.localSID), byte(s.remoteSID >> 24), byte(s.remoteSID >> 16), byte(s.remoteSID >> 8), byte(s.remoteSID)})