Open achinastone opened 3 weeks ago
` function TdwsXTimerQueue.Add(const AInterval: Cardinal; AEvent : TTimerEvent; const AOnTimer: TWaitOrTimerCallback): THandle; var Handle : THandle; Timer : TdwsXTimer; Event : epoll_event; begin Result := INVALID_HANDLE_VALUE;
Handle := timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); if Handle <> THandle(-1) then begin Timer := TdwsXTimer.Create; Timer.Handle := Handle; Timer.Interval := AInterval; Timer.OnTimer := AOnTimer; Timer.Event := AEvent;
Event.data.ptr := Timer;
Event.events := EPOLLIN or EPOLLET;
if epoll_ctl(_TimerQueuePool.Handle, EPOLL_CTL_ADD, Handle, @Event) <> -1 then
begin
if _SetInterval(Handle, AInterval) then
begin
_TimersLock.Enter;
try
_Timers.Add(Handle, Timer);
finally
_TimersLock.Leave;
end;
Result := Handle;
end else Timer.Free; //if _SetInterval return false then the Timer in the EPOLL will be invalid
end else
begin
__close(Handle);
Timer.Free;
end;
end; end; `
I have mentioned the problem about Timer( May be nil). The more serious problem is the Timer maybe a invalid value but not nil. ![Uploading Bug.png…]()