diff --git a/server.go b/server.go index a7ec306..784ad0e 100644 --- a/server.go +++ b/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 } }