ing
This commit is contained in:
parent
d13384841b
commit
52c900f0a2
13
server.go
13
server.go
|
@ -3,7 +3,6 @@ package server
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
@ -120,18 +119,18 @@ func runServer(s *server) {
|
|||
|
||||
func handleConnection(s *server, conn io.ReadWriteCloser, clientAddr string) {
|
||||
defer s.stopWg.Done()
|
||||
log.Printf("Connected: %s", clientAddr)
|
||||
stopChan := make(chan struct{})
|
||||
go s.serverHandler.Handle(clientAddr, conn, stopChan)
|
||||
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is connected.", clientAddr))
|
||||
clientStopChan := make(chan struct{})
|
||||
go s.serverHandler.Handle(clientAddr, conn, clientStopChan)
|
||||
|
||||
select {
|
||||
case <-s.stopChan:
|
||||
close(stopChan)
|
||||
close(clientStopChan)
|
||||
conn.Close()
|
||||
return
|
||||
case <-stopChan:
|
||||
case <-clientStopChan:
|
||||
conn.Close()
|
||||
log.Printf("Disconnected: %s", clientAddr)
|
||||
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", clientAddr))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user