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())) logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is connected.", conn.RemoteAddr()))
clientStopChan := make(chan struct{}) clientStopChan := make(chan struct{})
handleDoneCnah := make(chan struct{}) handleDoneChan := make(chan struct{})
go s.sh.Handle(conn, clientStopChan, handleDoneCnah) go s.sh.Handle(conn, clientStopChan, handleDoneChan)
select { select {
case <-s.stopChan: case <-s.stopChan:
close(clientStopChan) close(clientStopChan)
conn.Close() conn.Close()
<-handleDoneCnah <-handleDoneChan
case <-handleDoneCnah: case <-handleDoneChan:
close(clientStopChan) close(clientStopChan)
conn.Close() conn.Close()
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", conn.RemoteAddr())) logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", conn.RemoteAddr()))