Skip to content

Commit 1c1979d

Browse files
committed
Order shutdowns and keep sessions open if relevant. Revert shell changes
1 parent 7dc66f6 commit 1c1979d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

c2/httpserveshell/httpserveshell.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ func (serveShell *Server) Run(timeout int) {
164164
go func() {
165165
for {
166166
if sslshell.GetInstance().Channel().Shutdown.Load() {
167+
serveShell.Channel().Shutdown.Store(true)
167168
wg.Done()
168169

169170
break
@@ -176,6 +177,7 @@ func (serveShell *Server) Run(timeout int) {
176177
go func() {
177178
for {
178179
if simpleshell.GetServerInstance().Channel().Shutdown.Load() {
180+
serveShell.Channel().Shutdown.Store(true)
179181
wg.Done()
180182

181183
break
@@ -189,6 +191,13 @@ func (serveShell *Server) Run(timeout int) {
189191
wg.Add(1)
190192
go func() {
191193
httpservefile.GetInstance().Run(timeout)
194+
for {
195+
if serveShell.Channel().Shutdown.Load() {
196+
serveShell.Shutdown()
197+
198+
break
199+
}
200+
}
192201
}()
193202

194203
// wait until the go routines are clean up

c2/simpleshell/simpleshellserver.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ func (shellServer *Server) Run(timeout int) {
9595
go func() {
9696
time.Sleep(time.Duration(timeout) * time.Second)
9797
if !shellServer.Channel().HasSessions() {
98-
if shellServer.Channel().Shutdown.Load() {
99-
output.PrintFrameworkError("Timeout met. Shutting down shell listener.")
100-
shellServer.Channel().Shutdown.Store(true)
101-
}
98+
output.PrintFrameworkError("Timeout met. Shutting down shell listener.")
99+
shellServer.Channel().Shutdown.Store(true)
102100
}
103101
}()
104102
// Track if the shutdown is signaled for any reason.

0 commit comments

Comments
 (0)