diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-10 07:55:13 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-10 07:55:13 +0200 |
| commit | 0930b4c51191ec01cabc03779ef296153ed7f08a (patch) | |
| tree | 9c4a1b27340749cfafe8eaa94880e8d60279da50 /internal/probemanager/manager.go | |
| parent | d2ebb8cf2c5f0fccdd703cc64b9f8cecfb539bf9 (diff) | |
probemanager: surface cleanup destroy errors (task 417)
Diffstat (limited to 'internal/probemanager/manager.go')
| -rw-r--r-- | internal/probemanager/manager.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/internal/probemanager/manager.go b/internal/probemanager/manager.go index 7feb407..4c9dcec 100644 --- a/internal/probemanager/manager.go +++ b/internal/probemanager/manager.go @@ -150,13 +150,11 @@ func (m *Manager) Attach(syscall string) error { defer m.mu.Unlock() entry, err = m.entryLocked(syscall) if err != nil { - if enterLink != nil { - _ = enterLink.Destroy() - } - if exitLink != nil { - _ = exitLink.Destroy() - } - return err + return errors.Join( + err, + destroyLink(fmt.Sprintf("cleanup enter %s", syscall), enterLink), + destroyLink(fmt.Sprintf("cleanup exit %s", syscall), exitLink), + ) } if attachErr != nil { @@ -373,14 +371,21 @@ func attachPair(attacher Attacher, enterTP, exitTP string) (Link, Link, error) { exitLink, err := attachOne(attacher, exitTP) if err != nil { - if enterLink != nil { - _ = enterLink.Destroy() - } - return nil, nil, err + return nil, nil, errors.Join(err, destroyLink("cleanup enter link after exit attach failure", enterLink)) } return enterLink, exitLink, nil } +func destroyLink(action string, link Link) error { + if link == nil { + return nil + } + if err := link.Destroy(); err != nil { + return fmt.Errorf("%s: %w", action, err) + } + return nil +} + func attachOne(attacher Attacher, tracepoint string) (Link, error) { if tracepoint == "" { return nil, nil |
