diff --git a/pkg/auth/sip2/client.go b/pkg/auth/sip2/client.go index d52fe2a48b6624218ea7a7c60047dcc3b0d1ccf3..eca60c221adc72b3f6b6e014efe0afa2c682e9da 100644 --- a/pkg/auth/sip2/client.go +++ b/pkg/auth/sip2/client.go @@ -61,10 +61,10 @@ func newClient(host, port, location string) sipClient { return c } +// starts a dispatcher goroutine that ensures that all sip requests are serialized func (c *sipClient) startDispatcher() { go func() { - for { - req := <-c.reqQueue + for req := range c.reqQueue { resp, err := c.handleRequest(req.msg) req.respChan <- response{resp, err} } @@ -102,6 +102,7 @@ func (c *sipClient) sendRequest(msg string) (string, error) { return resp.msg, resp.err } +// handleRequest should not be used directly: dipatcher should be the only caller. use sendRequest instead. func (c *sipClient) handleRequest(msg string) (string, error) { err := telnetSend(c.conn, msg) if err != nil {