aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/manager
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-19 12:19:11 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-19 12:19:11 +0200
commita6b5a9f4d5c6bc485f90c7d6c8b3dfa371d0fa78 (patch)
treedd7faf73e1fd6540a873667860b0cbf54763aa6a /manager
parentmanager: wait for UIs to quit before quitting (diff)
downloadwireguard-windows-a6b5a9f4d5c6bc485f90c7d6c8b3dfa371d0fa78.tar.xz
wireguard-windows-a6b5a9f4d5c6bc485f90c7d6c8b3dfa371d0fa78.zip
manager: print panics on all go routines not just main one
Diffstat (limited to 'manager')
-rw-r--r--manager/service.go23
-rw-r--r--manager/updatestate.go2
2 files changed, 15 insertions, 10 deletions
diff --git a/manager/service.go b/manager/service.go
index 30567811..44b5456e 100644
--- a/manager/service.go
+++ b/manager/service.go
@@ -30,6 +30,17 @@ import (
type managerService struct{}
+func printPanic() {
+ if x := recover(); x != nil {
+ for _, line := range append([]string{fmt.Sprint(x)}, strings.Split(string(debug.Stack()), "\n")...) {
+ if len(strings.TrimSpace(line)) > 0 {
+ log.Println(line)
+ }
+ }
+ panic(x)
+ }
+}
+
func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) {
changes <- svc.Status{State: svc.StartPending}
@@ -50,16 +61,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
serviceError = services.ErrorRingloggerOpen
return
}
- defer func() {
- if x := recover(); x != nil {
- for _, line := range append([]string{fmt.Sprint(x)}, strings.Split(string(debug.Stack()), "\n")...) {
- if len(strings.TrimSpace(line)) > 0 {
- log.Println(line)
- }
- }
- panic(x)
- }
- }()
+ defer printPanic()
log.Println("Starting", version.UserAgent())
@@ -239,6 +241,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
goStartProcess := func(session uint32) {
procsGroup.Add(1)
go func() {
+ defer printPanic()
startProcess(session)
procsGroup.Done()
}()
diff --git a/manager/updatestate.go b/manager/updatestate.go
index 4b2cf1c1..b54cc367 100644
--- a/manager/updatestate.go
+++ b/manager/updatestate.go
@@ -24,6 +24,8 @@ const (
var updateState = UpdateStateUnknown
func checkForUpdates() {
+ defer printPanic()
+
if !version.IsRunningOfficialVersion() {
log.Println("Build is not official, so updates are disabled")
updateState = UpdateStateUpdatesDisabledUnofficialBuild