File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -573,7 +573,9 @@ func (s *Server) netServe() error {
573573 log .Debug ("Closing client connections..." )
574574 s .connsmu .RLock ()
575575 for _ , c := range s .conns {
576- c .closer .Close ()
576+ if c .closer != nil {
577+ c .closer .Close ()
578+ }
577579 }
578580 s .connsmu .RUnlock ()
579581 wg .Wait ()
@@ -595,7 +597,12 @@ func (s *Server) netServe() error {
595597 }
596598 wg .Add (1 )
597599 go func (conn net.Conn ) {
598- defer wg .Done ()
600+ detached := false
601+ defer func () {
602+ if ! detached {
603+ wg .Done ()
604+ }
605+ }()
599606
600607 // open connection
601608 // create the client
@@ -706,12 +713,15 @@ func (s *Server) netServe() error {
706713 client .in = InputStream {}
707714 client .pr .rd = rwc
708715 client .pr .wr = rwc
716+ client .closer = nil
717+ wg .Done ()
718+ detached = true
709719 log .Debugf ("Detached connection: %s" , client .remoteAddr )
710720
711- var wg sync.WaitGroup
712- wg .Add (1 )
721+ var wg2 sync.WaitGroup
722+ wg2 .Add (1 )
713723 go func () {
714- defer wg .Done ()
724+ defer wg2 .Done ()
715725 err := s .goLive (
716726 client .goLiveErr ,
717727 & liveConn {conn .RemoteAddr (), rwc },
@@ -723,7 +733,7 @@ func (s *Server) netServe() error {
723733 log .Error (err )
724734 }
725735 }()
726- wg .Wait ()
736+ wg2 .Wait ()
727737 return // close connection
728738 }
729739 log .Error (err )
You can’t perform that action at this time.
0 commit comments