Skip to content

Commit

Permalink
Merge pull request #20 from tserong/wip-fix-6484
Browse files Browse the repository at this point in the history
fix: ensure dbus connections are closed in (Try)RestartService
  • Loading branch information
bk201 authored Sep 3, 2024
2 parents 198df47 + 11ea70b commit 9576346
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/systemd-dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func RestartService(unit string) error {
logrus.Errorf("Failed to create new connection for systemd. err: %v", err)
return err
}
defer conn.Close()
responseChan := make(chan string, 1)
if _, err := conn.RestartUnitContext(ctx, unit, "fail", responseChan); err != nil {
logrus.Errorf("Failed to restart service %s. err: %v", unit, err)
Expand All @@ -32,6 +33,7 @@ func TryRestartService(unit string) error {
logrus.Errorf("Failed to create new connection for systemd. err: %v", err)
return err
}
defer conn.Close()
responseChan := make(chan string, 1)
if _, err := conn.TryRestartUnitContext(ctx, unit, "fail", responseChan); err != nil {
logrus.Errorf("Failed to restart service %s. err: %v", unit, err)
Expand Down

0 comments on commit 9576346

Please sign in to comment.