diff options
| author | Paul Buetow <35781042+pbuetow@users.noreply.github.com> | 2020-12-27 19:46:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-27 19:46:24 +0000 |
| commit | 495e9f38220a6d448b15882a235e7a9c21f21d18 (patch) | |
| tree | 5b59cade83108c1855d07f1f869a0dcb3b9f0907 /internal/server/server.go | |
| parent | b4db37d8cbae8f0c3dec289b2e1b0cfe83731415 (diff) | |
| parent | 2c7bdd09e8b7c58d98d631e32a24e4bd34d5bec9 (diff) | |
Merge pull request #16 from snonux/develop
Multiple minor enhancements.
Diffstat (limited to 'internal/server/server.go')
| -rw-r--r-- | internal/server/server.go | 24 |
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() { |
