ing
This commit is contained in:
parent
79d5056b0f
commit
1104f7e270
|
@ -3,6 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -119,7 +120,7 @@ func runServer(s *server) {
|
||||||
|
|
||||||
func handleConnection(s *server, conn io.ReadWriteCloser, clientAddr string) {
|
func handleConnection(s *server, conn io.ReadWriteCloser, clientAddr string) {
|
||||||
defer s.stopWg.Done()
|
defer s.stopWg.Done()
|
||||||
|
log.Printf("Connected: %s", clientAddr)
|
||||||
stopChan := make(chan struct{})
|
stopChan := make(chan struct{})
|
||||||
go s.serverHandler.Handle(clientAddr, conn, stopChan)
|
go s.serverHandler.Handle(clientAddr, conn, stopChan)
|
||||||
|
|
||||||
|
@ -128,5 +129,9 @@ func handleConnection(s *server, conn io.ReadWriteCloser, clientAddr string) {
|
||||||
close(stopChan)
|
close(stopChan)
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
|
case <-stopChan:
|
||||||
|
conn.Close()
|
||||||
|
log.Printf("Disconnected: %s", clientAddr)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user