From 032918a6c416c779efb706d4d2530cee687ebfaa Mon Sep 17 00:00:00 2001 From: plugwash Date: Sat, 20 Feb 2010 13:48:27 +0000 Subject: [PATCH] fix signal hang git-svn-id: file:///svnroot/lcore/trunk@82 b1de8a11-f9be-4011-bde0-cc7ace90066a --- lcoreselect.pas | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lcoreselect.pas b/lcoreselect.pas index df2501a..feb8ef8 100755 --- a/lcoreselect.pas +++ b/lcoreselect.pas @@ -93,7 +93,9 @@ var tempsocket : tlasio ; socketcount : integer ; // for debugging perposes :) dw,bt:integer; + 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 @@ -105,20 +107,22 @@ begin 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 inc(socketcount); - currentsocket := fdreverse[dw shl 5 or bt]; + fd := dw shl 5 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 +176,7 @@ begin end; end; *) { debugout('socketcount='+inttostr(socketcount));} + //writeln('leaving processasios'); end; procedure tselecteventcore.processmessages; @@ -327,6 +332,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 +342,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 +351,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 +362,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; -- 2.30.2