Skip to content

Commit 8a86b94

Browse files
AlexanderYastrebovneild
authored andcommitted
net/http: remove unused doneChan
The https://golang.org/cl/43230 removed use of `getDoneChan`. Change-Id: I33390c0e3aea6d98367363773ebe39d9c1f64ae9 GitHub-Last-Rev: fe1e415 GitHub-Pull-Request: #53172 Reviewed-on: https://go-review.googlesource.com/c/go/+/409538 Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: hopehook <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 2fc21b5 commit 8a86b94

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

src/net/http/server.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,37 +2680,11 @@ type Server struct {
26802680
mu sync.Mutex
26812681
listeners map[*net.Listener]struct{}
26822682
activeConn map[*conn]struct{}
2683-
doneChan chan struct{}
26842683
onShutdown []func()
26852684

26862685
listenerGroup sync.WaitGroup
26872686
}
26882687

2689-
func (s *Server) getDoneChan() <-chan struct{} {
2690-
s.mu.Lock()
2691-
defer s.mu.Unlock()
2692-
return s.getDoneChanLocked()
2693-
}
2694-
2695-
func (s *Server) getDoneChanLocked() chan struct{} {
2696-
if s.doneChan == nil {
2697-
s.doneChan = make(chan struct{})
2698-
}
2699-
return s.doneChan
2700-
}
2701-
2702-
func (s *Server) closeDoneChanLocked() {
2703-
ch := s.getDoneChanLocked()
2704-
select {
2705-
case <-ch:
2706-
// Already closed. Don't close again.
2707-
default:
2708-
// Safe to close here. We're the only closer, guarded
2709-
// by s.mu.
2710-
close(ch)
2711-
}
2712-
}
2713-
27142688
// Close immediately closes all active net.Listeners and any
27152689
// connections in state StateNew, StateActive, or StateIdle. For a
27162690
// graceful shutdown, use Shutdown.
@@ -2724,7 +2698,6 @@ func (srv *Server) Close() error {
27242698
srv.inShutdown.Store(true)
27252699
srv.mu.Lock()
27262700
defer srv.mu.Unlock()
2727-
srv.closeDoneChanLocked()
27282701
err := srv.closeListenersLocked()
27292702

27302703
// Unlock srv.mu while waiting for listenerGroup.
@@ -2776,7 +2749,6 @@ func (srv *Server) Shutdown(ctx context.Context) error {
27762749

27772750
srv.mu.Lock()
27782751
lnerr := srv.closeListenersLocked()
2779-
srv.closeDoneChanLocked()
27802752
for _, f := range srv.onShutdown {
27812753
go f()
27822754
}
@@ -3061,10 +3033,8 @@ func (srv *Server) Serve(l net.Listener) error {
30613033
for {
30623034
rw, err := l.Accept()
30633035
if err != nil {
3064-
select {
3065-
case <-srv.getDoneChan():
3036+
if srv.shuttingDown() {
30663037
return ErrServerClosed
3067-
default:
30683038
}
30693039
if ne, ok := err.(net.Error); ok && ne.Temporary() {
30703040
if tempDelay == 0 {

0 commit comments

Comments
 (0)