From 19e44013088ff80c11e1d7c045331b96f4dc41f0 Mon Sep 17 00:00:00 2001 From: beware Date: Fri, 7 Aug 2015 00:58:35 +0000 Subject: [PATCH] accept lasterror must be obtained before the rmasterset git-svn-id: file:///svnroot/lcore/trunk@142 b1de8a11-f9be-4011-bde0-cc7ace90066a --- lsocket.pas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); -- 2.30.2