/[lcore]/trunk/lcoreselect.pas
ViewVC logotype

Diff of /trunk/lcoreselect.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 57 by plugwash, Sat Oct 31 00:20:41 2009 UTC revision 135 by beware, Thu Mar 13 21:27:50 2014 UTC
# Line 21  Line 21 
21    {$ifdef VER1_0}    {$ifdef VER1_0}
22      linux,      linux,
23    {$else}    {$else}
24      baseunix,unix,unixutil,      baseunix,unix,unixutil,sockets,
25    {$endif}    {$endif}
26    fd_utils;    fd_utils;
27  var  var
# Line 64  Line 64 
64    
65  procedure processtimers;inline;  procedure processtimers;inline;
66  var  var
67    tv           ,tvnow     : ttimeval ;    tvnow     : ttimeval ;
68    currenttimer            : tltimer   ;    currenttimer            : tltimer   ;
69    temptimer               : tltimer  ;    temptimer               : tltimer  ;
70    
# Line 90  Line 90 
90  procedure processasios(var fdsr,fdsw:fdset);//inline;  procedure processasios(var fdsr,fdsw:fdset);//inline;
91  var  var
92    currentsocket : tlasio  ;    currentsocket : tlasio  ;
   tempsocket    : tlasio  ;  
93    socketcount   : integer ; // for debugging perposes :)    socketcount   : integer ; // for debugging perposes :)
94    dw,bt:integer;    dw,bt:integer;
95      currentfdword:fdword;
96      fd : integer;
97  begin  begin
98      //writeln('entering processasios');
99  {  inc(lcoretestcount);}  {  inc(lcoretestcount);}
100    
101      //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed      //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed
# Line 102  Line 104 
104    
105    {------- test optimised loop}    {------- test optimised loop}
106    socketcount := 0;    socketcount := 0;
107    for dw := (maxs shr 5) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin    for dw := (maxs shr fdwordshift) downto 0 do if (fdsr[dw] or fdsw[dw]) <> 0 then begin
108      for bt := 0 to 31 do if (fdsr[dw] or fdsw[dw]) and (1 shl bt) <> 0 then begin      currentfdword := (fdsr[dw] or fdsw[dw]);
109        for bt := fdwordmaxbit downto 0 do if currentfdword and (1 shl bt) <> 0 then begin
110        inc(socketcount);        inc(socketcount);
111        currentsocket := fdreverse[dw shl 5 or bt];        fd := dw shl fdwordshift or bt;
112          //writeln('reversing fd ',fd);
113          currentsocket := fdreverse[fd];
114        {if not assigned(currentsocket) then raise exception.create('currentsocket not assigned');        {if not assigned(currentsocket) then raise exception.create('currentsocket not assigned');
115        if currentsocket.fdhandlein < 0 then raise exception.create('currentsocket.fdhandlein out of range');}        if currentsocket.fdhandlein < 0 then raise exception.create('currentsocket.fdhandlein out of range');}
116        {i've seen the out of range case actually happening, so it can happen. test: just close the fd - beware}        {i've seen the out of range case actually happening, so it can happen. test: just close the fd - beware}
117        if not assigned(currentsocket) then begin        if not assigned(currentsocket) then begin
118          fdclose(dw shl 5 or bt);          fdclose(fd);
119          continue          continue
120        end;        end;
121        if currentsocket.fdhandlein < 0 then begin        if currentsocket.fdhandlein < 0 then begin
122          fdclose(dw shl 5 or bt);          fdclose(fd);
123          continue          continue
124        end;        end;
125        try        try
126          currentsocket.handlefdtrigger(fd_isset(currentsocket.fdhandlein,fdsr),fd_isset(currentsocket.fdhandleout,fdsw));          currentsocket.handlefdtrigger(fd_isset(fd,fdsr),fd_isset(fd,fdsw));
127        except        except
128          on E: exception do begin          on E: exception do begin
129            currentsocket.HandleBackGroundException(e);            currentsocket.HandleBackGroundException(e);
# Line 172  Line 177 
177      end;      end;
178    end; *)    end; *)
179  {  debugout('socketcount='+inttostr(socketcount));}  {  debugout('socketcount='+inttostr(socketcount));}
180      //writeln('leaving processasios');
181  end;  end;
182    
183  procedure tselecteventcore.processmessages;  procedure tselecteventcore.processmessages;
# Line 327  Line 333 
333    
334  procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean);  procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean);
335  begin  begin
336      //writeln('rmasterset called with fd ',fd);
337    if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');    if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');
338    if fd > maxs then maxs := fd;    if fd > maxs then maxs := fd;
339    if fd_isset(fd,fdsrmaster) then exit;    if fd_isset(fd,fdsrmaster) then exit;
# Line 336  Line 343 
343    
344  procedure tselecteventcore.rmasterclr(fd: integer);  procedure tselecteventcore.rmasterclr(fd: integer);
345  begin  begin
346      //writeln('rmasterclr called with fd ',fd);
347    if not fd_isset(fd,fdsrmaster) then exit;    if not fd_isset(fd,fdsrmaster) then exit;
348    fd_clr(fd,fdsrmaster);    fd_clr(fd,fdsrmaster);
349    
# Line 344  Line 352 
352    
353  procedure tselecteventcore.wmasterset(fd : integer);  procedure tselecteventcore.wmasterset(fd : integer);
354  begin  begin
355      //writeln('wmasterset called with fd ',fd);
356    if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');    if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');
357    if fd > maxs then maxs := fd;    if fd > maxs then maxs := fd;
358    
# Line 354  Line 363 
363    
364  procedure tselecteventcore.wmasterclr(fd: integer);  procedure tselecteventcore.wmasterclr(fd: integer);
365  begin  begin
366      //writeln('wmasterclr called with fd ',fd);
367    if not fd_isset(fd,fdswmaster) then exit;    if not fd_isset(fd,fdswmaster) then exit;
368    fd_clr(fd,fdswmaster);    fd_clr(fd,fdswmaster);
369  end;  end;

Legend:
Removed from v.57  
changed lines
  Added in v.135

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.22