This commit is contained in:
crusader 2017-11-28 02:08:53 +09:00
parent 6fbd3d2148
commit 4a4efdd0ef

View File

@ -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)