Skip to content

Commit

Permalink
fix: moving concurency on transaction layer with now increased perfor…
Browse files Browse the repository at this point in the history
…mance
  • Loading branch information
emiago committed Feb 9, 2024
1 parent 596d30d commit f418874
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions dialog_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func TestIntegrationDialog(t *testing.T) {
)
// Wait server to be ready
<-srvReady

// Client
{
ua, _ := NewUA()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions sip/transaction_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit f418874

Please sign in to comment.