mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
Experimental dead conn process kill logic
This commit is contained in:
parent
908a1bcda2
commit
871f9a200c
2 changed files with 11 additions and 1 deletions
|
@ -346,6 +346,9 @@ func runShellAs(who, hname, ttype, cmd string, interactive bool, //nolint:funlen
|
||||||
defer func() { goutmp.Unput_utmp(utmpx) }()
|
defer func() { goutmp.Unput_utmp(utmpx) }()
|
||||||
goutmp.Put_lastlog_entry("xs", who, pts, hname)
|
goutmp.Put_lastlog_entry("xs", who, pts, hname)
|
||||||
|
|
||||||
|
conn.Pproc = c.Process.Pid
|
||||||
|
//fmt.Printf("[process %d started]\n", c.Process.Pid)
|
||||||
|
|
||||||
log.Printf("[%s]\n", cmd)
|
log.Printf("[%s]\n", cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Command finished with error: %v", err)
|
log.Printf("Command finished with error: %v", err)
|
||||||
|
|
|
@ -39,6 +39,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
hkex "blitter.com/go/herradurakex"
|
hkex "blitter.com/go/herradurakex"
|
||||||
|
@ -87,6 +88,7 @@ type (
|
||||||
Cols uint16
|
Cols uint16
|
||||||
|
|
||||||
keepalive uint // if this reaches zero, conn is considered dead
|
keepalive uint // if this reaches zero, conn is considered dead
|
||||||
|
Pproc int // proc ID of command run on this conn
|
||||||
chaff ChaffConfig
|
chaff ChaffConfig
|
||||||
tuns *map[uint16](*TunEndpoint)
|
tuns *map[uint16](*TunEndpoint)
|
||||||
|
|
||||||
|
@ -1649,7 +1651,8 @@ func (hc *Conn) keepaliveHelper() {
|
||||||
time.Sleep(time.Duration(nextDuration) * time.Millisecond)
|
time.Sleep(time.Duration(nextDuration) * time.Millisecond)
|
||||||
hc.keepalive -= 1
|
hc.keepalive -= 1
|
||||||
logger.LogDebug(fmt.Sprintf("[keepAlive is now %d]\n", hc.keepalive))
|
logger.LogDebug(fmt.Sprintf("[keepAlive is now %d]\n", hc.keepalive))
|
||||||
//if rand.Intn(32) == 0 {
|
|
||||||
|
//if rand.Intn(8) == 0 {
|
||||||
// hc.keepalive = 0
|
// hc.keepalive = 0
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@ -1657,6 +1660,10 @@ func (hc *Conn) keepaliveHelper() {
|
||||||
logger.LogDebug(fmt.Sprintf("*** keepaliveHelper shutting down\n"))
|
logger.LogDebug(fmt.Sprintf("*** keepaliveHelper shutting down\n"))
|
||||||
hc.SetStatus(CSEConnDead)
|
hc.SetStatus(CSEConnDead)
|
||||||
hc.ShutdownKeepAlive()
|
hc.ShutdownKeepAlive()
|
||||||
|
if hc.Pproc != 0 {
|
||||||
|
//fmt.Printf("[pid %d needs to be killed]\n", hc.Pproc)
|
||||||
|
syscall.Kill(hc.Pproc, syscall.SIGABRT) //nolint:errcheck
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue