This commit is contained in:
crusader 2017-11-07 11:57:26 +09:00
parent 3b3f53cfa2
commit 3a437b10a4

View File

@ -126,15 +126,15 @@ func handleConnection(s *server, conn net.Conn) {
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is connected.", conn.RemoteAddr()))
clientStopChan := make(chan struct{})
handleDoneCnah := make(chan struct{})
go s.sh.Handle(conn, clientStopChan, handleDoneCnah)
handleDoneChan := make(chan struct{})
go s.sh.Handle(conn, clientStopChan, handleDoneChan)
select {
case <-s.stopChan:
close(clientStopChan)
conn.Close()
<-handleDoneCnah
case <-handleDoneCnah:
<-handleDoneChan
case <-handleDoneChan:
close(clientStopChan)
conn.Close()
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", conn.RemoteAddr()))