mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +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()
|
p.mu.Lock()
|
||||||
oldStatus := p.Status
|
oldStatus := p.Status
|
||||||
p.Status = status
|
p.Status = status
|
||||||
|
callback := p.onStatusChange // Capture callback reference
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
|
|
||||||
if p.onStatusChange != nil {
|
// Call callback outside the lock to prevent deadlocks
|
||||||
p.onStatusChange(oldStatus, status)
|
if callback != nil {
|
||||||
|
callback(oldStatus, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user