fs/session: fix deadlock in agent/new via setAgentLogLocked
SetAgentLog acquires sess.mu, but CreateAgent in create.go already holds sess.mu when calling it — causing a deadlock on agent/new writes. Split into SetAgentLog (locks) and setAgentLogLocked (no lock) so callers that already hold the lock can use the locked variant directly.
This commit is contained in:
parent
951fdc8133
commit
cb13f6523c
|
|
@ -264,12 +264,12 @@ func CreateAgent(rs *rootState, sessName string, args []string) error {
|
|||
ReadPlanStep: func() string {
|
||||
return ""
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
sess.mu.Lock()
|
||||
sess.Core = core
|
||||
sess.uname = uname
|
||||
sess.SetAgentLog(uname, al)
|
||||
sess.setAgentLogLocked(uname, al)
|
||||
sess.proc = proc
|
||||
sess.mu.Unlock()
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ func (sess *Session) AgentLog() *AgentLog {
|
|||
func (sess *Session) SetAgentLog(agentID string, al *AgentLog) {
|
||||
sess.mu.Lock()
|
||||
defer sess.mu.Unlock()
|
||||
sess.setAgentLogLocked(agentID, al)
|
||||
}
|
||||
|
||||
// setAgentLogLocked is like SetAgentLog but assumes sess.mu is already held.
|
||||
func (sess *Session) setAgentLogLocked(agentID string, al *AgentLog) {
|
||||
if sess.AgentLogs == nil {
|
||||
sess.AgentLogs = make(map[string]*AgentLog)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue