[PR #1480] [CLOSED] Fix hangs on SIGTERM. #2140

Closed
opened 2025-12-29 03:19:57 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1480
Author: @armooo
Created: 5/27/2023
Status: Closed

Base: mainHead: armooo-shutdown


📝 Commits (1)

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 hscontrol/app.go (+1 -1)

📄 Description

This fixes #1461, where two bugs prevent main from existing on SIGTERM.

The first is a blocking receiving from a cancel chanel which never have a, cancelStateUpdateChan. It seems closing the chanel should be all the is needed to signal the watching goroutines to exit.

The other is the signal hander never exiting an infinite for loop. The sigFunc is called in an errorGroup which blocks exiting Serve and thus main. It looks like a refactor in #1382 removed an os.Exit(0), replacing it with a return breaks out of the loop.

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1480 **Author:** [@armooo](https://github.com/armooo) **Created:** 5/27/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `armooo-shutdown` --- ### 📝 Commits (1) - [`5630f9e`](https://github.com/juanfont/headscale/commit/5630f9ef8ccda4b633697e6b4e948432bee28107) Fix hangs on SIGTERM. ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `hscontrol/app.go` (+1 -1) </details> ### 📄 Description This fixes #1461, where two bugs prevent main from existing on SIGTERM. The first is a blocking receiving from a cancel chanel which never have a, cancelStateUpdateChan. It seems closing the chanel should be all the is needed to signal the watching goroutines to exit. The other is the signal hander never exiting an infinite for loop. The sigFunc is called in an errorGroup which blocks exiting Serve and thus main. It looks like a refactor in #1382 removed an os.Exit(0), replacing it with a return breaks out of the loop. <!-- Headscale is "Open Source, acknowledged contribution", this means that any contribution will have to be discussed with the Maintainers before being submitted. This model has been chosen to reduce the risk of burnout by limiting the maintenance overhead of reviewing and validating third-party code. Headscale is open to code contributions for bug fixes without discussion. If you find mistakes in the documentation, please submit a fix to the documentation. --> <!-- Please tick if the following things apply. You… --> - [ ] read the [CONTRIBUTING guidelines](README.md#contributing) - [ ] raised a GitHub issue or discussed it on the projects chat beforehand - [ ] added unit tests - [ ] added integration tests - [ ] updated documentation if needed - [ ] updated CHANGELOG.md <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:19:57 +01:00
adam closed this issue 2025-12-29 03:19:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2140