X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/0ac6b47e810e6efaebcdbf3075b633e9b4109341..12873c59bfaeb05331a96c3611843aceedc899e0:/lcoreselect.pas?ds=sidebyside diff --git a/lcoreselect.pas b/lcoreselect.pas index 3cee9bf..38da6ba 100755 --- a/lcoreselect.pas +++ b/lcoreselect.pas @@ -21,7 +21,7 @@ uses {$ifdef VER1_0} linux, {$else} - baseunix,unix,unixutil, + baseunix,unix,unixutil,sockets, {$endif} fd_utils; var @@ -40,7 +40,7 @@ uses {$ifndef nosignal} lsignal, {$endif} - ltimevalstuff; + ltimevalstuff; {$include unixstuff.inc} @@ -64,7 +64,7 @@ type procedure processtimers;inline; var - tv ,tvnow : ttimeval ; + tvnow : ttimeval ; currenttimer : tltimer ; temptimer : tltimer ; @@ -90,10 +90,12 @@ end; procedure processasios(var fdsr,fdsw:fdset);//inline; var currentsocket : tlasio ; - tempsocket : tlasio ; socketcount : integer ; // for debugging perposes :) dw,bt:integer; + currentfdword:fdword; + fd : integer; begin + //writeln('entering processasios'); { inc(lcoretestcount);} //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed @@ -102,23 +104,26 @@ begin {------- test optimised loop} socketcount := 0; - for dw := (maxs shr 5) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin - for bt := 0 to 31 do if (fdsr[dw] or fdsw[dw]) and (1 shl bt) <> 0 then begin + for dw := (maxs shr fdwordshift) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin + currentfdword := (fdsr[dw] or fdsw[dw]); + for bt := fdwordmaxbit downto 0 do if currentfdword and (1 shl bt) <> 0 then begin inc(socketcount); - currentsocket := fdreverse[dw shl 5 or bt]; + fd := dw shl fdwordshift or bt; + //writeln('reversing fd ',fd); + currentsocket := fdreverse[fd]; {if not assigned(currentsocket) then raise exception.create('currentsocket not assigned'); if currentsocket.fdhandlein < 0 then raise exception.create('currentsocket.fdhandlein out of range');} {i've seen the out of range case actually happening, so it can happen. test: just close the fd - beware} if not assigned(currentsocket) then begin - fdclose(dw shl 5 or bt); + fdclose(fd); continue end; if currentsocket.fdhandlein < 0 then begin - fdclose(dw shl 5 or bt); + fdclose(fd); continue end; try - currentsocket.handlefdtrigger(fd_isset(currentsocket.fdhandlein,fdsr),fd_isset(currentsocket.fdhandleout,fdsw)); + currentsocket.handlefdtrigger(fd_isset(fd,fdsr),fd_isset(fd,fdsw)); except on E: exception do begin currentsocket.HandleBackGroundException(e); @@ -172,6 +177,7 @@ begin end; end; *) { debugout('socketcount='+inttostr(socketcount));} + //writeln('leaving processasios'); end; procedure tselecteventcore.processmessages; @@ -327,6 +333,7 @@ end; procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean); begin + //writeln('rmasterset called with fd ',fd); if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range'); if fd > maxs then maxs := fd; if fd_isset(fd,fdsrmaster) then exit; @@ -336,6 +343,7 @@ end; procedure tselecteventcore.rmasterclr(fd: integer); begin + //writeln('rmasterclr called with fd ',fd); if not fd_isset(fd,fdsrmaster) then exit; fd_clr(fd,fdsrmaster); @@ -344,6 +352,7 @@ end; procedure tselecteventcore.wmasterset(fd : integer); begin + //writeln('wmasterset called with fd ',fd); if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range'); if fd > maxs then maxs := fd; @@ -354,6 +363,7 @@ end; procedure tselecteventcore.wmasterclr(fd: integer); begin + //writeln('wmasterclr called with fd ',fd); if not fd_isset(fd,fdswmaster) then exit; fd_clr(fd,fdswmaster); end;