From ed0c669c6822f5869abecb2a0619f2a934eba529 Mon Sep 17 00:00:00 2001 From: evilolipop Date: Thu, 21 Dec 2023 09:22:22 +0800 Subject: [PATCH] fix: d less than 1 ms should not panic --- actor/actor_context.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/actor/actor_context.go b/actor/actor_context.go index d1d20b72..55de5dc0 100644 --- a/actor/actor_context.go +++ b/actor/actor_context.go @@ -214,19 +214,15 @@ func (ctx *actorContext) Unwatch(who *PID) { } func (ctx *actorContext) SetReceiveTimeout(d time.Duration) { - if d <= 0 { - panic("Duration must be greater than zero") + if d < time.Millisecond { + // anything less than 1 millisecond is set to zero + d = 0 } if d == ctx.receiveTimeout { return } - if d < time.Millisecond { - // anything less than 1 millisecond is set to zero - d = 0 - } - ctx.receiveTimeout = d ctx.ensureExtras()