diff --git a/servlet.go b/servlet.go index 7317842..2574b8c 100644 --- a/servlet.go +++ b/servlet.go @@ -39,6 +39,8 @@ type rpcServlet struct { stopChan chan struct{} stopWg sync.WaitGroup + + sendMtx sync.RWMutex } func (s *rpcServlet) Context() ServletContext { @@ -83,6 +85,7 @@ func (s *rpcServlet) Start(parentCTX cuc.Context, conn interface{}, doneChan cha } func (s *rpcServlet) Send(method string, args ...interface{}) (err error) { + s.sendMtx.RLock() noti := ¬ification{ method: method, args: args, @@ -92,7 +95,7 @@ func (s *rpcServlet) Send(method string, args ...interface{}) (err error) { } s.responseQueueChan <- rs - + s.sendMtx.RUnlock() return nil }