From 4a4efdd0eff632c516584996c01ebcbe313ecb00 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 28 Nov 2017 02:08:53 +0900 Subject: [PATCH] ing --- servlet.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/servlet.go b/servlet.go index db24038..0a5b61c 100644 --- a/servlet.go +++ b/servlet.go @@ -37,7 +37,7 @@ type servlet struct { stopWg sync.WaitGroup } -func (s *servlet) Start(parentCTX cuc.Context, reader interface{}, writer interface{}) error { +func (s *servlet) Start(parentCTX cuc.Context, reader interface{}, writer interface{}, doneChan chan<- struct{}) error { if nil == s.sh { panic("Servlet: servlet handler must be specified.") } @@ -65,7 +65,7 @@ func (s *servlet) Start(parentCTX cuc.Context, reader interface{}, writer interf s.messageQueueChan = make(chan *messageState, s.sh.GetPendingMessages()) s.stopWg.Add(1) - go handleServlet(s) + go handleServlet(s, doneChan) return nil } @@ -102,11 +102,13 @@ func (s *servlet) Context() ServletContext { return s.ctx } -func handleServlet(s *servlet) { +func handleServlet(s *servlet, doneChan chan<- struct{}) { defer s.stopWg.Done() - s.stopWg.Add(1) - go handleMessage(s) + messageStopChan := make(chan struct{}) + messageDoneChan := make(chan struct{}) + + go handleMessage(s, messageStopChan, messageDoneChan) for { requestCodec, err := s.sh.GetRequest(s.ctx, s.serverCodec, s.reader)