X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/032918a6c416c779efb706d4d2530cee687ebfaa..64005e4a670ae074eea1980c5eca131748884ec0:/lcoreselect.pas diff --git a/lcoreselect.pas b/lcoreselect.pas old mode 100755 new mode 100644 index feb8ef8..f613f67 --- a/lcoreselect.pas +++ b/lcoreselect.pas @@ -45,10 +45,10 @@ uses {$include unixstuff.inc} const - absoloutemaxs_select = (sizeof(fdset)*8)-1; + absolutemaxs_select = (sizeof(fdset)*8)-1; var - fdreverse:array[0..absoloutemaxs_select] of tlasio; + fdreverse:array[0..absolutemaxs_select] of tlasio; type tselecteventcore=class(teventcore) public @@ -64,7 +64,7 @@ type procedure processtimers;inline; var - tv ,tvnow : ttimeval ; + tvnow : ttimeval ; currenttimer : tltimer ; temptimer : tltimer ; @@ -90,24 +90,25 @@ end; procedure processasios(var fdsr,fdsw:fdset);//inline; var currentsocket : tlasio ; - tempsocket : tlasio ; - socketcount : integer ; // for debugging perposes :) + socketcount : integer ; // for debugging purposes :) 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 + //the message loop will exit if all lasios and ltimers and lsignals are destroyed //if (not assigned(firstasin)) and (not assigned(firsttimer)) and (not assigned(firstsignal)) then exit; {------- 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); - fd := 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'); @@ -143,7 +144,7 @@ begin - sockets which are released may not be freed because theyre never processed by the loop made new code for handling this, using asinreleaseflag - - when/why does the mustrefreshfds select apply, sheck if i did it correctly? + - when/why does the mustrefreshfds select apply, check if i did it correctly? - what happens if calling handlefdtrigger for a socket which does not have an event } @@ -287,7 +288,7 @@ begin repeat - //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed + //the message loop will exit if all lasios and ltimers and lsignals are destroyed processtasks; //currenttask := nil; {beware} @@ -309,7 +310,7 @@ begin end else begin gettimeofday(tvnow); - tv_substract(tv,tvnow); + tv_subtract(tv,tvnow); //writeln('timers active'); if tv.tv_sec < 0 then begin @@ -333,7 +334,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 > absolutemaxs then raise esocketexception.create('file descriptor out of range'); if fd > maxs then maxs := fd; if fd_isset(fd,fdsrmaster) then exit; fd_set(fd,fdsrmaster); @@ -352,7 +353,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 > absolutemaxs then raise esocketexception.create('file descriptor out of range'); if fd > maxs then maxs := fd; if fd_isset(fd,fdswmaster) then exit; @@ -381,7 +382,7 @@ begin inited := true; eventcore := tselecteventcore.create; - absoloutemaxs := absoloutemaxs_select; + absolutemaxs := absolutemaxs_select; maxs := 0; fd_zero(fdsrmaster);