Revert "fix(network): only trigger time sync when network transitions to online rather than every state change"

This reverts commit 86be6df1d3.
This commit is contained in:
Siyuan 2025-11-20 20:41:37 +00:00
parent 8a76a70d9e
commit ad4f7c09e1
2 changed files with 6 additions and 11 deletions

View File

@ -101,6 +101,11 @@ func supervise() error {
cmd.Args = os.Args
logFile, err := os.CreateTemp("", "jetkvm-stdout.log")
defer func() {
// we don't care about the errors here
_ = logFile.Close()
_ = os.Remove(logFile.Name())
}()
if err != nil {
return fmt.Errorf("failed to create log file: %w", err)
}
@ -128,8 +133,6 @@ func supervise() error {
}
if exiterr, ok := cmdErr.(*exec.ExitError); ok {
// createErrorDump will close and rename the file if successful
// Note: os.Exit bypasses defer, but file is already handled by createErrorDump
createErrorDump(logFile)
os.Exit(exiterr.ExitCode())
}

View File

@ -6,7 +6,6 @@ import (
"net"
"net/http"
"reflect"
"sync/atomic"
"time"
"github.com/jetkvm/kvm/internal/confparser"
@ -119,10 +118,6 @@ func setPublicIPReadyState(ipv4Ready, ipv6Ready bool) {
publicIPState.SetIPv4AndIPv6(ipv4Ready, ipv6Ready)
}
var (
isOnline = &atomic.Bool{}
)
func networkStateChanged(_ string, state types.InterfaceState) {
// do not block the main thread
go waitCtrlAndRequestDisplayUpdate(true, "network_state_changed")
@ -131,10 +126,7 @@ func networkStateChanged(_ string, state types.InterfaceState) {
writeJSONRPCEvent("networkState", state.ToRpcInterfaceState(), currentSession)
}
previousOnline := isOnline.Load()
isOnline.Store(state.Online)
if state.Online && !previousOnline {
if state.Online {
networkLogger.Info().Msg("network state changed to online, triggering time sync")
triggerTimeSyncOnNetworkStateChange()
}