lcore.org gitweb
/
lcore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix regression: memory leak in processtasks. also the repeating task fix needs curren...
[lcore.git]
/
lcoreselect.pas
diff --git
a/lcoreselect.pas
b/lcoreselect.pas
old mode 100755
(executable)
new mode 100644
(file)
index
659bfce
..
ad81600
--- a/
lcoreselect.pas
+++ b/
lcoreselect.pas
@@
-45,10
+45,10
@@
uses
{$include unixstuff.inc}
\r
\r
const
\r
{$include unixstuff.inc}
\r
\r
const
\r
- absol
o
utemaxs_select = (sizeof(fdset)*8)-1;
\r
+ absolutemaxs_select = (sizeof(fdset)*8)-1;
\r
\r
var
\r
\r
var
\r
- fdreverse:array[0..absol
o
utemaxs_select] of tlasio;
\r
+ fdreverse:array[0..absolutemaxs_select] of tlasio;
\r
type
\r
tselecteventcore=class(teventcore)
\r
public
\r
type
\r
tselecteventcore=class(teventcore)
\r
public
\r
@@
-64,12
+64,12
@@
type
\r
procedure processtimers;inline;
\r
var
\r
\r
procedure processtimers;inline;
\r
var
\r
- tv
,tv
now : ttimeval ;
\r
+ tvnow : ttimeval ;
\r
currenttimer : tltimer ;
\r
temptimer : tltimer ;
\r
\r
begin
\r
currenttimer : tltimer ;
\r
temptimer : tltimer ;
\r
\r
begin
\r
- gettime
ofday
(tvnow);
\r
+ gettime
monotonic
(tvnow);
\r
currenttimer := firsttimer;
\r
while assigned(currenttimer) do begin
\r
//writeln(currenttimer.enabled);
\r
currenttimer := firsttimer;
\r
while assigned(currenttimer) do begin
\r
//writeln(currenttimer.enabled);
\r
@@
-90,8
+90,7
@@
end;
procedure processasios(var fdsr,fdsw:fdset);//inline;
\r
var
\r
currentsocket : tlasio ;
\r
procedure processasios(var fdsr,fdsw:fdset);//inline;
\r
var
\r
currentsocket : tlasio ;
\r
- tempsocket : tlasio ;
\r
- socketcount : integer ; // for debugging perposes :)
\r
+ socketcount : integer ; // for debugging purposes :)
\r
dw,bt:integer;
\r
currentfdword:fdword;
\r
fd : integer;
\r
dw,bt:integer;
\r
currentfdword:fdword;
\r
fd : integer;
\r
@@
-99,7
+98,7
@@
begin
//writeln('entering processasios');
\r
{ inc(lcoretestcount);}
\r
\r
//writeln('entering processasios');
\r
{ inc(lcoretestcount);}
\r
\r
- //the message loop will exit if all lasio
's and ltimer's and lsignal'
s are destroyed
\r
+ //the message loop will exit if all lasio
s and ltimers and lsignal
s are destroyed
\r
//if (not assigned(firstasin)) and (not assigned(firsttimer)) and (not assigned(firstsignal)) then exit;
\r
\r
\r
//if (not assigned(firstasin)) and (not assigned(firsttimer)) and (not assigned(firstsignal)) then exit;
\r
\r
\r
@@
-145,7
+144,7
@@
begin
- sockets which are released may not be freed because theyre never processed by the loop
\r
made new code for handling this, using asinreleaseflag
\r
\r
- sockets which are released may not be freed because theyre never processed by the loop
\r
made new code for handling this, using asinreleaseflag
\r
\r
- - when/why does the mustrefreshfds select apply,
s
heck if i did it correctly?
\r
+ - when/why does the mustrefreshfds select apply,
c
heck if i did it correctly?
\r
\r
- what happens if calling handlefdtrigger for a socket which does not have an event
\r
}
\r
\r
- what happens if calling handlefdtrigger for a socket which does not have an event
\r
}
\r
@@
-191,7
+190,7
@@
begin
prepsigpipe;
\r
{$endif}
\r
selectresult := select(maxs+1,@fdsr,@fdsw,nil,0);
\r
prepsigpipe;
\r
{$endif}
\r
selectresult := select(maxs+1,@fdsr,@fdsw,nil,0);
\r
- while (selectresult>0) or assigned(firsttask)
or assigned(currenttask)
do begin;
\r
+ while (selectresult>0) or assigned(firsttask) do begin;
\r
\r
processtasks;
\r
processtimers;
\r
\r
processtasks;
\r
processtimers;
\r
@@
-250,7
+249,7
@@
begin
fd_zero(FDSW);
\r
if result=-1 then begin
\r
if linuxerror = SYS_EINTR then begin
\r
fd_zero(FDSW);
\r
if result=-1 then begin
\r
if linuxerror = SYS_EINTR then begin
\r
- // we received a signal it
'
s not a problem
\r
+ // we received a signal it
i
s not a problem
\r
end else begin
\r
raise esocketexception.create('select returned error '+inttostr(linuxerror));
\r
end;
\r
end else begin
\r
raise esocketexception.create('select returned error '+inttostr(linuxerror));
\r
end;
\r
@@
-289,7
+288,7
@@
begin
\r
repeat
\r
\r
\r
repeat
\r
\r
- //the message loop will exit if all lasio
's and ltimer's and lsignal'
s are destroyed
\r
+ //the message loop will exit if all lasio
s and ltimers and lsignal
s are destroyed
\r
processtasks;
\r
//currenttask := nil;
\r
{beware}
\r
processtasks;
\r
//currenttask := nil;
\r
{beware}
\r
@@
-310,8
+309,8
@@
begin
selectresult := doselect(nil);
\r
\r
end else begin
\r
selectresult := doselect(nil);
\r
\r
end else begin
\r
- gettime
ofday
(tvnow);
\r
- tv_sub
s
tract(tv,tvnow);
\r
+ gettime
monotonic
(tvnow);
\r
+ tv_subtract(tv,tvnow);
\r
\r
//writeln('timers active');
\r
if tv.tv_sec < 0 then begin
\r
\r
//writeln('timers active');
\r
if tv.tv_sec < 0 then begin
\r
@@
-335,7
+334,7
@@
end;
procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean);
\r
begin
\r
//writeln('rmasterset called with fd ',fd);
\r
procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean);
\r
begin
\r
//writeln('rmasterset called with fd ',fd);
\r
- if fd > absol
outemaxs then raise esocketexception.create('file di
scriptor out of range');
\r
+ if fd > absol
utemaxs then raise esocketexception.create('file de
scriptor out of range');
\r
if fd > maxs then maxs := fd;
\r
if fd_isset(fd,fdsrmaster) then exit;
\r
fd_set(fd,fdsrmaster);
\r
if fd > maxs then maxs := fd;
\r
if fd_isset(fd,fdsrmaster) then exit;
\r
fd_set(fd,fdsrmaster);
\r
@@
-354,7
+353,7
@@
end;
procedure tselecteventcore.wmasterset(fd : integer);
\r
begin
\r
//writeln('wmasterset called with fd ',fd);
\r
procedure tselecteventcore.wmasterset(fd : integer);
\r
begin
\r
//writeln('wmasterset called with fd ',fd);
\r
- if fd > absol
outemaxs then raise esocketexception.create('file di
scriptor out of range');
\r
+ if fd > absol
utemaxs then raise esocketexception.create('file de
scriptor out of range');
\r
if fd > maxs then maxs := fd;
\r
\r
if fd_isset(fd,fdswmaster) then exit;
\r
if fd > maxs then maxs := fd;
\r
\r
if fd_isset(fd,fdswmaster) then exit;
\r
@@
-383,7
+382,7
@@
begin
inited := true;
\r
eventcore := tselecteventcore.create;
\r
\r
inited := true;
\r
eventcore := tselecteventcore.create;
\r
\r
- absol
outemaxs := absolo
utemaxs_select;
\r
+ absol
utemaxs := absol
utemaxs_select;
\r
\r
maxs := 0;
\r
fd_zero(fdsrmaster);
\r
\r
maxs := 0;
\r
fd_zero(fdsrmaster);
\r