From f418874fd88849eb461df7d5befe70687cd9c06b Mon Sep 17 00:00:00 2001 From: Emir Aganovic Date: Fri, 9 Feb 2024 18:55:31 +0100 Subject: [PATCH] fix: moving concurency on transaction layer with now increased performance --- dialog_integration_test.go | 3 +-- server.go | 4 ++-- sip/transaction_layer.go | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dialog_integration_test.go b/dialog_integration_test.go index d2f34b5..c0faf52 100644 --- a/dialog_integration_test.go +++ b/dialog_integration_test.go @@ -79,7 +79,6 @@ func TestIntegrationDialog(t *testing.T) { ) // Wait server to be ready <-srvReady - // Client { ua, _ := NewUA() @@ -107,7 +106,7 @@ func TestIntegrationDialog(t *testing.T) { go srv.ListenAndServe(ctx, "udp", contactHDR.Address.HostPort()) // Wait server to be ready <-srvReady - time.Sleep(200 * time.Millisecond) + time.Sleep(200 * time.Millisecond) // just to avoid race with listeners on UDP t.Run("UAS hangup", func(t *testing.T) { // INVITE diff --git a/server.go b/server.go index 43954b2..ea07468 100644 --- a/server.go +++ b/server.go @@ -242,8 +242,8 @@ func (srv *Server) ServeWSS(l net.Listener) error { func (srv *Server) onRequest(req *sip.Request, tx sip.ServerTransaction) { // Transaction layer is the one who controls concurency execution of every request // so in this case we should avoid adding more concurency - // srv.handleRequest(req, tx) - go srv.handleRequest(req, tx) + srv.handleRequest(req, tx) + // go srv.handleRequest(req, tx) } // handleRequest must be run in seperate goroutine diff --git a/sip/transaction_layer.go b/sip/transaction_layer.go index 6c646cd..c32332f 100644 --- a/sip/transaction_layer.go +++ b/sip/transaction_layer.go @@ -64,11 +64,11 @@ func (txl *TransactionLayer) handleMessage(msg Message) { switch msg := msg.(type) { case *Request: - // go txl.handleRequest(msg) - txl.handleRequest(msg) + go txl.handleRequest(msg) + // txl.handleRequest(msg) case *Response: - // go txl.handleResponse(msg) - txl.handleResponse(msg) + go txl.handleResponse(msg) + // txl.handleResponse(msg) default: txl.log.Error().Msg("unsupported message, skip it") }