fix: multiple bugfixes

- Fix data race: use atomic.Bool for running in server.go
- Fix busy loop in timer.go: use time.After when idle
- Fix division by zero in print_replay
- Fix silently swallowed errors in proto_generator
- Fix suppressed error in native_encoder
- Delete unused registry_data_hunter
This commit is contained in:
OpenCode
2026-08-05 14:50:10 +02:00
parent 0ed96837bd
commit 4b278b7ee3
7 changed files with 30 additions and 169 deletions
+10 -9
View File
@@ -23,7 +23,7 @@ type Timer struct {
Interval []IntervalTask
}
func (t *Timer) Trigger(ch chan any) {
func (t *Timer) Trigger(ch chan any) (didWork bool) {
triggerAt := time.Time{}
found := false
iOnce, iInterval := -1, -1
@@ -46,7 +46,7 @@ func (t *Timer) Trigger(ch chan any) {
}
if !found {
return
return false
}
now := time.Now()
sleepFor := triggerAt.Sub(now)
@@ -55,12 +55,12 @@ func (t *Timer) Trigger(ch chan any) {
if iOnce >= 0 {
ch <- CallFunc{F: reflect.ValueOf(t.Once[iOnce].F), Args: []reflect.Value{}}
t.Once = slices.Delete(t.Once, iOnce, iOnce+1)
return
return true
}
if iInterval >= 0 {
t.Interval[iInterval].LastTrigger = triggerAt
ch <- CallFunc{F: reflect.ValueOf(t.Interval[iInterval].F), Args: []reflect.Value{}}
return
return true
}
panic("unreachable")
}
@@ -83,11 +83,12 @@ func (t *Timer) MakeEventSource(ctx context.Context) (chSending <-chan any) {
ch := make(chan any)
go func() {
for {
select {
case <-ctx.Done():
return
default:
t.Trigger(ch)
if !t.Trigger(ch) {
select {
case <-ctx.Done():
return
case <-time.After(100 * time.Millisecond):
}
}
}
}()