From 1104f7e270b304bf96e885af5dbeef4d0c71a5ff Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 27 Oct 2017 12:47:10 +0900 Subject: [PATCH] ing --- server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 7e88116..9ccbe1e 100644 --- a/server.go +++ b/server.go @@ -3,6 +3,7 @@ package server import ( "fmt" "io" + "log" "net" "sync" "sync/atomic" @@ -119,7 +120,7 @@ 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) @@ -128,5 +129,9 @@ func handleConnection(s *server, conn io.ReadWriteCloser, clientAddr string) { close(stopChan) conn.Close() return + case <-stopChan: + conn.Close() + log.Printf("Disconnected: %s", clientAddr) + return } }