mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-11 16:09:07 +02:00
[client] Keep tray quit state across an aborted Windows session end
An aborted session end (WM_ENDSESSION with wParam == 0) cleared the shared shutdown flag, re-enabling hide-on-close cancels and dialogs while a tray quit was still tearing down. Track the session-end and tray-quit sources as separate flags; aborting a session end only clears its own state.
This commit is contained in:
@@ -2,16 +2,23 @@ package services
|
|||||||
|
|
||||||
import "sync/atomic"
|
import "sync/atomic"
|
||||||
|
|
||||||
var shuttingDown atomic.Bool
|
var (
|
||||||
|
sessionEnding atomic.Bool
|
||||||
|
quitting atomic.Bool
|
||||||
|
)
|
||||||
|
|
||||||
func BeginShutdown() {
|
func BeginSessionEnd() {
|
||||||
shuttingDown.Store(true)
|
sessionEnding.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AbortShutdown() {
|
func AbortSessionEnd() {
|
||||||
shuttingDown.Store(false)
|
sessionEnding.Store(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BeginShutdown() {
|
||||||
|
quitting.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShuttingDown() bool {
|
func ShuttingDown() bool {
|
||||||
return shuttingDown.Load()
|
return sessionEnding.Load() || quitting.Load()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ func endSessionInterceptor() func(hwnd uintptr, msg uint32, wParam, lParam uintp
|
|||||||
return func(_ uintptr, msg uint32, wParam, _ uintptr) (uintptr, bool) {
|
return func(_ uintptr, msg uint32, wParam, _ uintptr) (uintptr, bool) {
|
||||||
switch msg {
|
switch msg {
|
||||||
case wmQueryEndSession:
|
case wmQueryEndSession:
|
||||||
services.BeginShutdown()
|
services.BeginSessionEnd()
|
||||||
return 1, true
|
return 1, true
|
||||||
case wmEndSession:
|
case wmEndSession:
|
||||||
if wParam == 0 {
|
if wParam == 0 {
|
||||||
services.AbortShutdown()
|
services.AbortSessionEnd()
|
||||||
return 0, true
|
return 0, true
|
||||||
}
|
}
|
||||||
log.Info("windows session is ending; exiting immediately")
|
log.Info("windows session is ending; exiting immediately")
|
||||||
|
|||||||
Reference in New Issue
Block a user