From 7bb4eb2e5444ef6b383b9c70a82a1c157074acd9 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 11 Feb 2020 20:30:44 +0100 Subject: [docs] comment on unsafe method --- pkg/auth/sip2/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/auth/sip2/client.go b/pkg/auth/sip2/client.go index d52fe2a..eca60c2 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 { -- cgit v1.2.3