mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 05:45:59 +02:00
* Fixed TInetSocket.Connect error handling which got broken in r39199
git-svn-id: trunk@39533 -
This commit is contained in:
parent
a721f23666
commit
3c18e12cc7
@ -1045,7 +1045,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
fpgetsockopt(ASocket, SOL_SOCKET, SO_ERROR, @Err, @ErrLen);
|
fpgetsockopt(ASocket, SOL_SOCKET, SO_ERROR, @Err, @ErrLen);
|
||||||
if Err <> 0 then // 0 -> connected
|
if Err <> 0 then // 0 -> connected
|
||||||
Result := Err;
|
// We are not interested in the real error-code (ESysEAGAIN,
|
||||||
|
// ESysEINTR etc, which values are positive)
|
||||||
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$else}
|
{$else}
|
||||||
@ -1072,12 +1074,11 @@ Var
|
|||||||
A : THostAddr;
|
A : THostAddr;
|
||||||
addr: TInetSockAddr;
|
addr: TInetSockAddr;
|
||||||
Res : Integer;
|
Res : Integer;
|
||||||
|
Err: Integer;
|
||||||
{$IFDEF HAVENONBLOCKING}
|
{$IFDEF HAVENONBLOCKING}
|
||||||
FDS: TFDSet;
|
FDS: TFDSet;
|
||||||
TimeV: TTimeVal;
|
TimeV: TTimeVal;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
A := StrToHostAddr(FHost);
|
A := StrToHostAddr(FHost);
|
||||||
if A.s_bytes[1] = 0 then
|
if A.s_bytes[1] = 0 then
|
||||||
@ -1097,16 +1098,25 @@ begin
|
|||||||
SetSocketBlockingMode(Handle, bmNonBlocking, @FDS) ;
|
SetSocketBlockingMode(Handle, bmNonBlocking, @FDS) ;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
Res:=ESysEINTR;
|
Err:=ESysEINTR;
|
||||||
While (Res=ESysEINTR) do
|
Res:=-1;
|
||||||
|
While (Res<0) and (Err in [ESysEINTR, ESysEAGAIN]) do
|
||||||
{$endif}
|
{$endif}
|
||||||
|
begin
|
||||||
Res:=fpConnect(Handle, @addr, sizeof(addr));
|
Res:=fpConnect(Handle, @addr, sizeof(addr));
|
||||||
|
{$ifdef unix}
|
||||||
|
if Res < 0 then
|
||||||
|
Err:=socketerror;
|
||||||
|
{$else}
|
||||||
|
Err:=Res;
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
{$IFDEF HAVENONBLOCKING}
|
{$IFDEF HAVENONBLOCKING}
|
||||||
if (ConnectTimeOut>0) then
|
if (Err=ESysEINPROGRESS) and (ConnectTimeOut>0) then
|
||||||
begin
|
begin
|
||||||
Res:=CheckSocketConnectTimeout(Handle, @FDS, @TimeV);
|
Res:=CheckSocketConnectTimeout(Handle, @FDS, @TimeV);
|
||||||
SetSocketBlockingMode(Handle, bmBlocking, @FDS);
|
SetSocketBlockingMode(Handle, bmBlocking, @FDS);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
If Not (Res<0) then
|
If Not (Res<0) then
|
||||||
if not FHandler.Connect then
|
if not FHandler.Connect then
|
||||||
|
Loading…
Reference in New Issue
Block a user