summaryrefslogtreecommitdiff
path: root/internal/server/server.go
diff options
context:
space:
mode:
authorPaul Buetow <git@mx.buetow.org>2020-12-26 10:48:51 +0000
committerPaul Buetow <git@mx.buetow.org>2020-12-26 10:48:51 +0000
commitab676c2b484225ed22765b23d8f0545088ecd610 (patch)
tree5292e21339fef551f19e8fdd90beeb35d676381d /internal/server/server.go
parentb4db37d8cbae8f0c3dec289b2e1b0cfe83731415 (diff)
code cleanup and minor refactorings
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go24
1 files changed, 2 insertions, 22 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 31fa85d..a20737e 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -7,7 +7,6 @@ import (
"io"
"net"
"strings"
- "time"
"github.com/mimecast/dtail/internal/config"
"github.com/mimecast/dtail/internal/io/logger"
@@ -33,9 +32,6 @@ type Server struct {
sched *scheduler
// Mointor log files for pattern (if configured)
cont *continuous
- // Wait counter, e.g. there might be still subprocesses (forked by drun) to be killed.
- // TODO: Remove this counter.
- shutdownWaitFor chan struct{}
}
// New returns a new server.
@@ -46,7 +42,6 @@ func New() *Server {
sshServerConfig: &gossh.ServerConfig{},
catLimiter: make(chan struct{}, config.Server.MaxConcurrentCats),
tailLimiter: make(chan struct{}, config.Server.MaxConcurrentTails),
- shutdownWaitFor: make(chan struct{}, 1000),
sched: newScheduler(),
cont: newContinuous(),
}
@@ -80,27 +75,12 @@ func (s *Server) Start(ctx context.Context) int {
go s.cont.start(ctx)
go s.listenerLoop(ctx, listener)
- select {
- case <-ctx.Done():
- // Wait until all commands/jobs/children are no more!
- s.wait()
- }
+ <-ctx.Done()
// For future use.
return 0
}
-func (s *Server) wait() {
- for {
- num := len(s.shutdownWaitFor)
- logger.Debug("Waiting for stuff to finish", num)
- if num <= 0 {
- return
- }
- time.Sleep(time.Second)
- }
-}
-
func (s *Server) listenerLoop(ctx context.Context, listener net.Listener) {
logger.Debug("Starting listener loop")
@@ -180,7 +160,7 @@ func (s *Server) handleRequests(ctx context.Context, sshConn gossh.Conn, in <-ch
case config.ControlUser:
handler = handlers.NewControlHandler(user)
default:
- handler = handlers.NewServerHandler(user, s.catLimiter, s.tailLimiter, s.shutdownWaitFor)
+ handler = handlers.NewServerHandler(user, s.catLimiter, s.tailLimiter)
}
terminate := func() {