From d749b95e732340e0186c0bf806eb3ce7b13f26a4 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 11 Apr 2024 16:39:43 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E7=A1=AE=E4=BF=9D=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eGLock.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eGLock.erl b/src/eGLock.erl index b830875..97637b3 100644 --- a/src/eGLock.erl +++ b/src/eGLock.erl @@ -44,7 +44,7 @@ lockApply(Key, MFAOrFun, TimeOut, LastTime) -> lockApply(Key, MFAOrFun, TimeOut, LastTime); _ -> CurTime = erlang:system_time(microsecond), - NewTimeOut = TimeOut - max(CurTime - LastTime, 0), + NewTimeOut = max(0, TimeOut - max(CurTime - LastTime, 0)), lockApply(Key, MFAOrFun, NewTimeOut, CurTime) end after TimeOut -> @@ -76,7 +76,7 @@ lockApplys(Keys, MFAOrFun, TimeOut, LastTime) -> lockApplys(Keys, MFAOrFun, TimeOut, LastTime); _ -> CurTime = erlang:system_time(microsecond), - NewTimeOut = TimeOut - max(CurTime - LastTime, 0), + NewTimeOut = max(0, TimeOut - max(CurTime - LastTime, 0)), lockApplys(Keys, MFAOrFun, NewTimeOut, CurTime) end after TimeOut ->