mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 09:04:27 +00:00
Refactor SetStatus method to capture onStatusChange callback reference before unlocking mutex
This commit is contained in:
@@ -30,10 +30,12 @@ func (p *Process) SetStatus(status InstanceStatus) {
|
||||
p.mu.Lock()
|
||||
oldStatus := p.Status
|
||||
p.Status = status
|
||||
callback := p.onStatusChange // Capture callback reference
|
||||
p.mu.Unlock()
|
||||
|
||||
if p.onStatusChange != nil {
|
||||
p.onStatusChange(oldStatus, status)
|
||||
// Call callback outside the lock to prevent deadlocks
|
||||
if callback != nil {
|
||||
callback(oldStatus, status)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user