2.0.4: pthread_cond_timedwait needs absolute time (from crossbuilder, issue #7196)

git-svn-id: trunk@4296 -
This commit is contained in:
micha 2006-07-25 20:34:20 +00:00
parent f5a902b2ee
commit d0e0ef3d8c

View File

@ -554,10 +554,18 @@ procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
p : pintrtlevent;
errres : cint;
timespec : ttimespec;
tnow : timeval;
begin
p:=pintrtlevent(aevent);
timespec.tv_sec:=timeout div 1000;
timespec.tv_nsec:=(timeout mod 1000)*1000000;
fpgettimeofday(@tnow,nil);
timespec.tv_sec:=tnow.tv_sec+(timeout div 1000);
timespec.tv_nsec:=(timeout mod 1000)*1000000 + tnow.tv_usec*1000;
if timespec.tv_nsec >= 1000000000 then
begin
inc(timespec.tv_sec);
dec(timespec.tv_nsec, 1000000000);
end;
errres:=pthread_cond_timedwait(@p^.condvar, @p^.mutex, @timespec);
if (errres=0) or (errres=ESysETIMEDOUT) then
pthread_mutex_unlock(@p^.mutex);