From: beware Date: Fri, 7 Aug 2015 00:58:35 +0000 (+0000) Subject: accept lasterror must be obtained before the rmasterset X-Git-Url: http://www.lcore.org/git/lcore.git/commitdiff_plain/19e44013088ff80c11e1d7c045331b96f4dc41f0 accept lasterror must be obtained before the rmasterset git-svn-id: file:///svnroot/lcore/trunk@142 b1de8a11-f9be-4011-bde0-cc7ace90066a --- diff --git a/lsocket.pas b/lsocket.pas index 4596f6b..f359a55 100644 --- a/lsocket.pas +++ b/lsocket.pas @@ -534,7 +534,7 @@ function tlsocket.accept : longint; var FromAddrSize : LongInt; // i don't really know what to do with these at this FromAddr : TInetSockAddrV; // at this point time will tell :) - a:integer; + a,acceptlasterror:integer; begin {$ifdef secondlistener} if (lastsessionfromsecond) then begin @@ -550,11 +550,14 @@ begin {$else} result := system_accept(fdhandlein,fromaddr,fromaddrsize); {$endif} + + if (result = -1) then acceptlasterror := {$ifdef mswindows}getlasterror{$else}socketerror{$endif} else acceptlasterror := 0; + //now we have accepted one request start monitoring for more again eventcore.rmasterset(fdhandlein,true); if result = -1 then begin - raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting'); + raise esocketexception.create('error '+inttostr(acceptlasterror)+' while accepting'); end; if result > absolutemaxs then begin myfdclose(result);