Fix handling of connections without process
This commit is contained in:
@@ -69,13 +69,16 @@ func cleanConnections() (activePIDs map[int]struct{}) {
|
|||||||
PID: process.UndefinedProcessID,
|
PID: process.UndefinedProcessID,
|
||||||
}, now)
|
}, now)
|
||||||
|
|
||||||
activePIDs[conn.process.Pid] = struct{}{}
|
// Step 2: mark as ended
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
// Step 2: mark end
|
|
||||||
conn.Ended = nowUnix
|
conn.Ended = nowUnix
|
||||||
conn.Save()
|
conn.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the connection has an associated process, add its PID to the active PID list.
|
||||||
|
if conn.process != nil {
|
||||||
|
activePIDs[conn.process.Pid] = struct{}{}
|
||||||
|
}
|
||||||
case conn.Ended < deleteOlderThan:
|
case conn.Ended < deleteOlderThan:
|
||||||
// Step 3: delete
|
// Step 3: delete
|
||||||
// DEBUG:
|
// DEBUG:
|
||||||
|
|||||||
@@ -656,14 +656,21 @@ func (conn *Connection) Failed(reason, reasonOptionKey string) {
|
|||||||
func (conn *Connection) SetVerdict(newVerdict Verdict, reason, reasonOptionKey string, reasonCtx interface{}) (ok bool) {
|
func (conn *Connection) SetVerdict(newVerdict Verdict, reason, reasonOptionKey string, reasonCtx interface{}) (ok bool) {
|
||||||
conn.SetVerdictDirectly(newVerdict)
|
conn.SetVerdictDirectly(newVerdict)
|
||||||
|
|
||||||
|
// Set reason and context.
|
||||||
conn.Reason.Msg = reason
|
conn.Reason.Msg = reason
|
||||||
conn.Reason.Context = reasonCtx
|
conn.Reason.Context = reasonCtx
|
||||||
|
|
||||||
|
// Reset option key.
|
||||||
conn.Reason.OptionKey = ""
|
conn.Reason.OptionKey = ""
|
||||||
conn.Reason.Profile = ""
|
conn.Reason.Profile = ""
|
||||||
if reasonOptionKey != "" && conn.Process() != nil {
|
|
||||||
conn.Reason.OptionKey = reasonOptionKey
|
// Set option key if data is available.
|
||||||
conn.Reason.Profile = conn.Process().Profile().GetProfileSource(conn.Reason.OptionKey)
|
if reasonOptionKey != "" {
|
||||||
|
lp := conn.Process().Profile()
|
||||||
|
if lp != nil {
|
||||||
|
conn.Reason.OptionKey = reasonOptionKey
|
||||||
|
conn.Reason.Profile = lp.GetProfileSource(conn.Reason.OptionKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true // TODO: remove
|
return true // TODO: remove
|
||||||
|
|||||||
@@ -111,7 +111,8 @@ func CleanProcessStorage(activePIDs map[int]struct{}) {
|
|||||||
// The PID of a process does not change.
|
// The PID of a process does not change.
|
||||||
|
|
||||||
// Check if this is a special process.
|
// Check if this is a special process.
|
||||||
if p.Pid == UnidentifiedProcessID || p.Pid == SystemProcessID {
|
switch p.Pid {
|
||||||
|
case UnidentifiedProcessID, UnsolicitedProcessID, SystemProcessID:
|
||||||
p.profile.MarkStillActive()
|
p.profile.MarkStillActive()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user