Jelajahi Sumber

Merged revisions 7733,7860,8202,8222,8261 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r7733 | Almindor | 2007-06-19 22:07:19 +0200 (Tue, 19 Jun 2007) | 2 lines

* update lNet to 0.5.2

........
r7860 | Almindor | 2007-06-30 10:20:08 +0200 (Sat, 30 Jun 2007) | 2 lines

* update lnet to 0.5.3

........
r8202 | Almindor | 2007-07-31 11:45:46 +0200 (Tue, 31 Jul 2007) | 2 lines

* update lNet to 0.5.5

........
r8222 | Almindor | 2007-08-05 11:50:55 +0200 (Sun, 05 Aug 2007) | 2 lines

* update lNet in fppkg to 0.5.6a

........
r8261 | peter | 2007-08-11 18:16:39 +0200 (Sat, 11 Aug 2007) | 2 lines

* remove poNoConsole so it works under windows

........

git-svn-id: branches/fixes_2_2@8438 -

peter 18 tahun lalu
induk
melakukan
c412c1f55c

+ 39 - 8
utils/fppkg/lnet/lcommon.pp

@@ -53,10 +53,14 @@ const
   {$IFDEF UNIX}
   INVALID_SOCKET = -1;
   SOCKET_ERROR = -1;
-    {$IFDEF LINUX} // TODO: fix this crap, some don't even have MSD_NOSIGNAL
+    {$IFDEF LINUX} // TODO: fix this crap, some don't even have MSG_NOSIGNAL
     LMSG = MSG_NOSIGNAL;
     {$ELSE}
-    LMSG = $20000; // FPC BUG in 2.0.4-
+      {$IFDEF FREEBSD}
+        LMSG = $20000; // FPC BUG in 2.0.4-, freeBSD value
+      {$ELSE}
+        LMSG = 0;
+      {$ENDIF}
     {$ENDIF}
   {$ENDIF}
   { Default Values }
@@ -101,32 +105,59 @@ uses
 
 {$IFDEF WINDOWS}
   , Windows;
+  
+{$IFDEF WINCE}
 
 function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
+const
+  MAX_ERROR = 1024;
 var
   Tmp: string;
   TmpW: widestring;
 begin
   Result := '[' + IntToStr(Ernum) + '] ';
+    SetLength(TmpW, MAX_ERROR);
+    SetLength(TmpW, FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM or
+                                   FORMAT_MESSAGE_IGNORE_INSERTS or
+                                   FORMAT_MESSAGE_ARGUMENT_ARRAY,
+                                   nil, Ernum, 0, @TmpW[1], MAX_ERROR, nil));
+    Tmp := UTF8Encode(TmpW);
+  if Length(Tmp) > 2 then
+    Delete(Tmp, Length(Tmp)-1, 2);
+  Result := Tmp;
+end;
+
+{$ELSE} // any other windows
+
+function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
+const
+  MAX_ERROR = 1024;
+var
+  Tmp: string;
+  TmpW: widestring;
+begin
+  Result := ' [' + IntToStr(Ernum) + ']: ';
   if USEUtf8 then begin
-    SetLength(TmpW, 256);
+    SetLength(TmpW, MAX_ERROR);
     SetLength(TmpW, FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM or
                                    FORMAT_MESSAGE_IGNORE_INSERTS or
                                    FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                                   nil, Ernum, 0, @TmpW[1], 256, nil));
+                                   nil, Ernum, 0, @TmpW[1], MAX_ERROR, nil));
     Tmp := UTF8Encode(TmpW);
   end else begin
-    SetLength(Tmp, 256);
+    SetLength(Tmp, MAX_ERROR);
     SetLength(Tmp, FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM or
                                  FORMAT_MESSAGE_IGNORE_INSERTS or
                                  FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                                 nil, Ernum, 0, @Tmp[1], 256, nil));
+                                 nil, Ernum, 0, @Tmp[1], MAX_ERROR, nil));
   end;
   if Length(Tmp) > 2 then
     Delete(Tmp, Length(Tmp)-1, 2);
-  Result := Tmp;
+  Result := Result + Tmp;
 end;
 
+{$ENDIF}
+
 function TZSeconds: integer; inline;
 var
   lInfo: Windows.TIME_ZONE_INFORMATION;
@@ -238,7 +269,7 @@ end;
 
 function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
 begin
-  Result := '[' + IntToStr(Ernum) + '] ' + Errors.StrError(Ernum);
+  Result := ' [' + IntToStr(Ernum) + ']: ' + Errors.StrError(Ernum);
 end;
 
 function LSocketError: Longint;

+ 25 - 14
utils/fppkg/lnet/levents.pp

@@ -140,8 +140,8 @@ type
     FFreeRoot: TLHandle; // the root of "free" list if any
     FFreeIter: TLHandle; // the last of "free" list if any
     FInLoop: Boolean;
-    function GetTimeout: DWord; virtual;
-    procedure SetTimeout(const Value: DWord); virtual;
+    function GetTimeout: Integer; virtual;
+    procedure SetTimeout(const Value: Integer); virtual;
     function Bail(const msg: string; const Ernum: Integer): Boolean;
     procedure AddForFree(aHandle: TLHandle);
     procedure FreeHandles;
@@ -162,7 +162,7 @@ type
     procedure Clear;
     procedure AddRef;
     procedure DeleteRef;
-    property Timeout: DWord read GetTimeout write SetTimeout;
+    property Timeout: Integer read GetTimeout write SetTimeout;
     property OnError: TLEventerErrorEvent read FOnError write FOnError;
     property Count: Integer read FCount;
   end;
@@ -176,8 +176,8 @@ type
     FReadFDSet: TFDSet;
     FWriteFDSet: TFDSet;
     FErrorFDSet: TFDSet;
-    function GetTimeout: DWord; override;
-    procedure SetTimeout(const Value: DWord); override;
+    function GetTimeout: Integer; override;
+    procedure SetTimeout(const Value: Integer); override;
     procedure ClearSets;
    public
     constructor Create; override;
@@ -301,12 +301,12 @@ begin
   Clear;
 end;
 
-function TLEventer.GetTimeout: DWord;
+function TLEventer.GetTimeout: Integer;
 begin
   Result := 0;
 end;
 
-procedure TLEventer.SetTimeout(const Value: DWord);
+procedure TLEventer.SetTimeout(const Value: Integer);
 begin
 end;
 
@@ -314,7 +314,7 @@ function TLEventer.Bail(const msg: string; const Ernum: Integer): Boolean;
 begin
   Result := False; // always false, substitute for caller's result
   if Assigned(FOnError) then
-    FOnError(msg + '[' + IntToStr(Ernum) + ']: ' + LStrError(Ernum), Self);
+    FOnError(msg + LStrError(Ernum), Self);
 end;
 
 procedure TLEventer.AddForFree(aHandle: TLHandle);
@@ -467,15 +467,23 @@ begin
   FTimeout.tv_usec := 0;
 end;
 
-function TLSelectEventer.GetTimeout: DWord;
+function TLSelectEventer.GetTimeout: Integer;
 begin
-  Result := (FTimeout.tv_sec * 1000) + FTimeout.tv_usec;
+  if FTimeout.tv_sec < 0 then
+    Result := -1
+  else
+    Result := (FTimeout.tv_sec * 1000) + FTimeout.tv_usec;
 end;
 
-procedure TLSelectEventer.SetTimeout(const Value: DWord);
+procedure TLSelectEventer.SetTimeout(const Value: Integer);
 begin
-  FTimeout.tv_sec := Value div 1000;
-  FTimeout.tv_usec := Value mod 1000;
+  if Value >= 0 then begin
+    FTimeout.tv_sec := Value div 1000;
+    FTimeout.tv_usec := Value mod 1000;
+  end else begin
+    FTimeout.tv_sec := -1;
+    FTimeout.tv_usec := 0;
+  end;
 end;
 
 procedure TLSelectEventer.ClearSets;
@@ -522,7 +530,10 @@ begin
   end;
 
   TempTime := FTimeout;
-  n := fpSelect(MaxHandle + 1, @FReadFDSet, @FWriteFDSet, @FErrorFDSet, @TempTime);
+  if FTimeout.tv_sec >= 0 then
+    n := fpSelect(MaxHandle + 1, @FReadFDSet, @FWriteFDSet, @FErrorFDSet, @TempTime)
+  else
+    n := fpSelect(MaxHandle + 1, @FReadFDSet, @FWriteFDSet, @FErrorFDSet, nil);
   
   if n < 0 then
     Bail('Error on select', LSocketError);

+ 6 - 4
utils/fppkg/lnet/lftp.pp

@@ -31,6 +31,9 @@ interface
 uses
   Classes, lNet, lTelnet;
   
+const
+  DEFAULT_FTP_PORT    = 1025;
+
 type
   TLFTP = class;
   TLFTPClient = class;
@@ -88,7 +91,7 @@ type
     property SocketClass: TLSocketClass read GetSocketClass write SetSocketClass;
     property ControlConnection: TLTelnetClient read FControl;
     property DataConnection: TLTCP read FData;
-    property TransferMethod: TLFTPTransferMethod read FTransferMethod write FTransferMethod;
+    property TransferMethod: TLFTPTransferMethod read FTransferMethod write FTransferMethod default ftPassive;
   end;
 
   { TLFTPTelnetClient }
@@ -203,7 +206,7 @@ type
     property Binary: Boolean read GetBinary write SetBinary;
     property PipeLine: Boolean read FPipeLine write FPipeLine;
     property Echo: Boolean read GetEcho write SetEcho;
-    property StartPort: Word read FStartPort write FStartPort;
+    property StartPort: Word read FStartPort write FStartPort default DEFAULT_FTP_PORT;
     property Transfer: Boolean read GetTransfer;
 
     property OnError: TLSocketErrorEvent read FOnError write FOnError;
@@ -224,7 +227,6 @@ uses
 
 const
   FLE             = #13#10;
-  DEFAULT_PORT    = 1024;
 
   EMPTY_REC: TLFTPStatusRec = (Status: fsNone; Args: ('', ''));
 
@@ -352,7 +354,7 @@ begin
   FStatusSet := []; // empty Event set
   FPassWord := '';
   FChunkSize := DEFAULT_CHUNK;
-  FStartPort := DEFAULT_PORT;
+  FStartPort := DEFAULT_FTP_PORT;
   FSL := TStringList.Create;
   FLastPort := FStartPort;
 

+ 44 - 30
utils/fppkg/lnet/lnet.pp

@@ -1,4 +1,4 @@
-{ lNet v0.5.1
+{ lNet v0.5.6
 
   CopyRight (C) 2004-2006 Ales Katona
 
@@ -345,6 +345,7 @@ type
 
     function GetConnected: Boolean; override;
     function GetConnecting: Boolean;
+    function GetCount: Integer; override;
 
     procedure ConnectAction(aSocket: TLHandle); override;
     procedure AcceptAction(aSocket: TLHandle); override;
@@ -408,8 +409,9 @@ destructor TLSocket.Destroy;
 begin
   if Assigned(FOnFree) then
     FOnFree(Self);
+
+  inherited Destroy; // important! must be called before disconnect
   Disconnect;
-  inherited Destroy;
 end;
 
 procedure TLSocket.Disconnect;
@@ -437,14 +439,14 @@ procedure TLSocket.LogError(const msg: string; const ernum: Integer);
 begin
   if Assigned(FOnError) then
     if ernum > 0 then
-      FOnError(Self, msg + '[' + IntToStr(ernum) + ']: ' + LStrError(ernum))
+      FOnError(Self, msg + LStrError(ernum))
     else
       FOnError(Self, msg);
 end;
 
 function TLSocket.Bail(const msg: string; const ernum: Integer): Boolean;
 begin
-  Result  :=  False; // return the result for the caller
+  Result := False; // return the result for the caller
 
   Disconnect;
   LogError(msg, ernum);
@@ -464,9 +466,10 @@ var
   a: TSockAddr;
   l: Integer;
 begin
+  Result := '';
   l := SizeOf(a);
-  fpGetSockName(FHandle, @a, @l);
-  Result := HostAddrToStr(LongWord(a.sin_addr));
+  if fpGetSockName(FHandle, @a, @l) = 0 then
+    Result := NetAddrToStr(LongWord(a.sin_addr));
 end;
 
 function TLSocket.CanSend: Boolean;
@@ -502,7 +505,8 @@ end;
 
 function TLSocket.Get(var aData; const aSize: Integer): Integer;
 var
-  AddressLength: Integer = SizeOf(FAddress);
+  AddressLength: Integer = SizeOf(FPeerAddress);
+  LastError: Longint;
 begin
   Result := 0;
   if CanReceive then begin
@@ -513,10 +517,12 @@ begin
     if Result = 0 then
       Disconnect;
     if Result = SOCKET_ERROR then begin
-      if IsBlockError(LSocketError) then begin
+      LastError := LSocketError;
+      if IsBlockError(LastError) then begin
         FCanReceive  :=  False;
         IgnoreRead  :=  False;
-      end else Bail('Receive Error', LSocketError);
+      end else
+        Bail('Receive Error', LastError);
       Result := 0;
     end;
   end;
@@ -543,16 +549,15 @@ begin
     Done := true;
     FHandle := fpSocket(AF_INET, FSocketType, FProtocol);
     if FHandle = INVALID_SOCKET then
-      Bail('Socket error', LSocketError);
+      Exit(Bail('Socket error', LSocketError));
     SetOptions;
     if FSocketType = SOCK_DGRAM then begin
       Arg := 1;
       if fpsetsockopt(FHandle, SOL_SOCKET, SO_BROADCAST, @Arg, Sizeof(Arg)) = SOCKET_ERROR then
-        Bail('SetSockOpt error', LSocketError);
+        Exit(Bail('SetSockOpt error', LSocketError));
     end;
     
     FillAddressInfo(FAddress, AF_INET, Address, aPort);
-
     FillAddressInfo(FPeerAddress, AF_INET, LADDR_BR, aPort);
 
     Result  :=  Done;
@@ -561,7 +566,7 @@ end;
 
 function TLSocket.GetLocalPort: Word;
 begin
-  Result := FAddress.sin_port;
+  Result := ntohs(FAddress.sin_port);
 end;
 
 function TLSocket.GetPeerPort: Word;
@@ -580,7 +585,7 @@ begin
       Result := true;
     if (FSocketType = SOCK_STREAM) and Result then
       if fpListen(FHandle, FListenBacklog) = SOCKET_ERROR then
-        Result  :=  Bail('Error on Listen', LSocketError)
+        Result := Bail('Error on Listen', LSocketError)
       else
         Result := true;
   end;
@@ -620,20 +625,25 @@ begin
 end;
 
 function TLSocket.Send(const aData; const aSize: Integer): Integer;
+var
+  LastError: Longint;
 begin
   Result := 0;
   if not FServerSocket then begin
-    if aSize <= 0 then
+    if aSize <= 0 then begin
       Bail('Send error: wrong size (Size <= 0)', -1);
+      Exit(0);
+    end;
 
     if CanSend then begin
       Result := DoSend(aData, aSize);
       if Result = SOCKET_ERROR then begin
-        if IsBlockError(LSocketError) then begin
+        LastError := LSocketError;
+        if IsBlockError(LastError) then begin
           FCanSend := False;
           IgnoreWrite := False;
         end else
-          Bail('Send error', LSocketError);
+          Bail('Send error', LastError);
         Result := 0;
       end;
     end;
@@ -845,7 +855,7 @@ procedure TLUdp.Disconnect;
 begin
   if Assigned(FRootSock) then begin
     FRootSock.Disconnect;
-    FreeAndNil(FRootSock);
+    FRootSock := nil; // even if the old one exists, eventer takes care of it
   end;
 end;
 
@@ -861,11 +871,11 @@ begin
 
   Result := FRootSock.SetupSocket(APort, LADDR_ANY);
   
-  FillAddressInfo(FRootSock.FPeerAddress, AF_INET, Address, aPort);
-
-  FRootSock.FConnected := true;
-  if Result then
+  if Result then begin
+    FillAddressInfo(FRootSock.FPeerAddress, AF_INET, Address, aPort);
+    FRootSock.FConnected := true;
     RegisterWithEventer;
+  end;
 end;
 
 function TLUdp.Listen(const APort: Word; const AIntf: string = LADDR_ANY): Boolean;
@@ -883,8 +893,8 @@ begin
   
     FRootSock.FConnected := True;
     RegisterWithEventer;
+    Result := True;
   end;
-  Result := FRootSock.Connected;
 end;
 
 function TLUdp.Bail(const msg: string): Boolean;
@@ -1038,7 +1048,7 @@ begin
     FIterator := FRootSock;
     RegisterWithEventer;
   end else begin
-    FreeAndNil(FRootSock);
+    FreeAndNil(FRootSock); // one possible use, since we're not in eventer yet
     FIterator := nil;
   end;
 end;
@@ -1055,6 +1065,7 @@ begin
   if FRootSock.Listen(APort, AIntf) then begin
     FRootSock.FConnected := True;
     FRootSock.FServerSocket := True;
+    FIterator := FRootSock;
     RegisterWithEventer;
     Result := true;
   end;
@@ -1111,10 +1122,7 @@ end;
 
 procedure TLTcp.IterReset;
 begin
-  if Assigned(FRootSock) and FRootSock.FServerSocket then
-    FIterator := FRootSock.NextSock
-  else
-    FIterator := FRootSock;
+  FIterator := FRootSock;
 end;
 
 procedure TLTcp.Disconnect;
@@ -1160,8 +1168,9 @@ begin
     end;
     FRootSock.FNextSock := Tmp;
     Tmp.FPrevSock := FRootSock;
-    if not Assigned(FIterator) then
-      FIterator := Tmp;
+    if not Assigned(FIterator)      // if we don't have (bug?) an iterator yet
+    or FIterator.FServerSocket then // or if it's the first socket accepted
+      FIterator := Tmp;  // assign it as iterator (don't assign later acceptees)
     Inc(FCount);
     FEventer.AddHandle(Tmp);
     AcceptEvent(Tmp);
@@ -1226,6 +1235,11 @@ begin
     Result := FRootSock.Connecting;
 end;
 
+function TLTcp.GetCount: Integer;
+begin
+  Result := FCount;
+end;
+
 function TLTcp.Get(var aData; const aSize: Integer; aSocket: TLSocket): Integer;
 begin
   Result := 0;

+ 26 - 34
utils/fppkg/lnet/sys/lepolleventer.inc

@@ -49,14 +49,17 @@ begin
   inherited Destroy;
 end;
 
-function TLEpollEventer.GetTimeout: DWord;
+function TLEpollEventer.GetTimeout: Integer;
 begin
-  Result := DWord(FTimeout);
+  Result := FTimeout;
 end;
 
-procedure TLEpollEventer.SetTimeout(const Value: DWord);
+procedure TLEpollEventer.SetTimeout(const Value: Integer);
 begin
-  FTimeout := cInt(Value);
+  if Value >= 0 then
+    FTimeout := Value
+  else
+    FTimeout := -1;
 end;
 
 procedure TLEpollEventer.HandleIgnoreRead(aHandle: TLHandle);
@@ -129,19 +132,19 @@ begin
   MasterChanges := epoll_wait(FEpollMasterFD, @MasterEvents[0], 2, FTimeout);
 
   if MasterChanges > 0 then begin
-    for i := 0 to MasterChanges-1 do
+    for i := 0 to MasterChanges - 1 do
       if MasterEvents[i].Data.fd = FEpollFD then
         Changes := epoll_wait(FEpollFD, @FEvents[0], FCount, 0)
       else
         ReadChanges := epoll_wait(FEpollReadFD, @FEventsRead[0], FCount, 0);
     if (Changes < 0) or (ReadChanges < 0) then
-      Bail('Error on epoll: ', LSocketError)
+      Bail('Error on epoll', LSocketError)
     else
       Result := Changes + ReadChanges > 0;
       
     if Result then begin
       FInLoop := True;
-      for i := 0 to Max(Changes, ReadChanges)-1 do begin
+      for i := 0 to Max(Changes, ReadChanges) - 1 do begin
         Temp := nil;
         if i < Changes then begin
           Temp := TLHandle(FEvents[i].data.ptr);
@@ -176,7 +179,7 @@ begin
           if  (not Temp.FDispose)
           and (FEvents[i].events and EPOLLERR = EPOLLERR) then
             if Assigned(Temp.FOnError) and not Temp.IgnoreError then
-              Temp.FOnError(Temp, 'Handle error: ' + LStrError(LSocketError));
+              Temp.FOnError(Temp, 'Handle error' + LStrError(LSocketError));
 
           if Temp.FDispose then
             AddForFree(Temp);
@@ -187,38 +190,27 @@ begin
         FreeHandles;
     end;
   end else if MasterChanges < 0 then
-    Bail('Error on epoll: ', LSocketError);
+    Bail('Error on epoll', LSocketError);
 end;
 
 function BestEventerClass: TLEventerClass;
-
-  function GetVersion(s: string): Integer;
-  const
-    Numbers = ['0'..'9'];
-  var
-    i: Integer;
-  begin
-    s := StringReplace(s, '.', '', [rfReplaceAll]);
-    i := 1;
-    while (i <= Length(s)) and (s[i] in Numbers) do
-      Inc(i);
-    s := Copy(s, 1, i - 1);
-    if Length(s) < 4 then // varies OS to OS
-      Insert('0', s, 3); // in linux, last part can be > 10
-    Result := StrToInt(s);
-  end;
-
-{$ifndef DISABLE_EPOLL}
 var
-  u: TUTSName;
-{$endif}
+  tmp: THandle;
 begin
-  Result := TLSelectEventer;
-{$ifndef DISABLE_EPOLL}
-  if fpUname(u) = 0 then   // check for 2.6+
-    if GetVersion(u.release) >= 2600 then
+  {$IFNDEF FORCE_SELECT}
+  try
+    tmp := epoll_create(1);
+    if tmp >= 0 then begin
+      FpClose(tmp);
       Result := TLEpollEventer;
-{$endif}
+    end else
+      Result := TLSelectEventer;
+  except
+    Result := TLSelectEventer;
+  end;
+  {$ELSE}
+  Result := TLSelectEventer;
+  {$ENDIF}
 end;
 
 {$endif} // Linux

+ 2 - 2
utils/fppkg/lnet/sys/lepolleventerh.inc

@@ -18,8 +18,8 @@
     FEpollFD: THandle;       // this one monitors ET style for other
     FEpollMasterFD: THandle; // this one monitors the first two
     FFreeList: TFPObjectList;
-    function GetTimeout: DWord; override;
-    procedure SetTimeout(const Value: DWord); override;
+    function GetTimeout: Integer; override;
+    procedure SetTimeout(const Value: Integer); override;
     procedure HandleIgnoreRead(aHandle: TLHandle); override;
     procedure Inflate;
    public

+ 21 - 7
utils/fppkg/lnet/sys/lkqueueeventer.inc

@@ -22,15 +22,20 @@ begin
   inherited Destroy;
 end;
 
-function TLKQueueEventer.GetTimeout: DWord;
+function TLKQueueEventer.GetTimeout: Integer;
 begin
   Result := FTimeout.tv_sec + FTimeout.tv_nsec * 1000 * 1000;
 end;
 
-procedure TLKQueueEventer.SetTimeout(const Value: DWord);
+procedure TLKQueueEventer.SetTimeout(const Value: Integer);
 begin
-  FTimeout.tv_sec := Value div 1000;
-  FTimeout.tv_nsec := (Value mod 1000) * 1000;
+  if Value >= 0 then begin
+    FTimeout.tv_sec := Value div 1000;
+    FTimeout.tv_nsec := (Value mod 1000) * 1000;
+  end else begin
+    FTimeout.tv_sec := -1;
+    FTimeout.tv_nsec := 0;
+  end;
 end;
 
 procedure TLKQueueEventer.HandleIgnoreRead(aHandle: TLHandle);
@@ -85,11 +90,16 @@ var
   i, n: Integer;
   Temp: TLHandle;
 begin
-  n := KEvent(FQueue, @FChanges[0], FFreeSlot,
-            @FEvents[0], Length(FEvents), @FTimeout);
+  if FTimeout.tv_sec >= 0 then
+    n := KEvent(FQueue, @FChanges[0], FFreeSlot,
+              @FEvents[0], Length(FEvents), @FTimeout)
+  else
+    n := KEvent(FQueue, @FChanges[0], FFreeSlot,
+              @FEvents[0], Length(FEvents), nil);
+
   FFreeSlot := 0;
   if n < 0 then
-    Bail('Error on kqueue: ', LSocketError);
+    Bail('Error on kqueue', LSocketError);
   Result := n > 0;
   if Result then begin
     FInLoop := True;
@@ -122,7 +132,11 @@ end;
 
 function BestEventerClass: TLEventerClass;
 begin
+  {$IFNDEF FORCE_SELECT}
   Result := TLKQueueEventer;
+  {$ELSE}
+  Result := TLSelectEventer;
+  {$ENDIF}
 end;
 
 {$endif} // BSD

+ 2 - 2
utils/fppkg/lnet/sys/lkqueueeventerh.inc

@@ -11,8 +11,8 @@
     FChanges: array of TKEvent;
     FFreeSlot: Integer;
     FQueue: THandle;
-    function GetTimeout: DWord; override;
-    procedure SetTimeout(const Value: DWord); override;
+    function GetTimeout: Integer; override;
+    procedure SetTimeout(const Value: Integer); override;
     procedure HandleIgnoreRead(aHandle: TLHandle); override;
     procedure Inflate;
    public

+ 6 - 6
utils/fppkg/pkgglobals.pp

@@ -44,8 +44,8 @@ var
 
 Implementation
 
-// define use_shell to use sysutils.executeprocess 
-//  as alternate to using 'process' in getcompilerinfo 
+// define use_shell to use sysutils.executeprocess
+//  as alternate to using 'process' in getcompilerinfo
 {$IFDEF GO32v2}
  {$DEFINE USE_SHELL}
 {$ENDIF GO32v2}
@@ -60,8 +60,8 @@ Implementation
 
 uses
   typinfo,
-{$IFNDEF USE_SHELL}  
-  process, 
+{$IFNDEF USE_SHELL}
+  process,
 {$ENDIF USE_SHELL}
   contnrs,
   uriparser,
@@ -214,7 +214,7 @@ end;
 
 //
 // if use_shell defined uses sysutils.executeprocess else uses 'process'
-//  
+//
 function GetCompilerInfo(const ACompiler,AOptions:string):string;
 const
   BufSize = 1024;
@@ -245,7 +245,7 @@ begin
 {$ELSE USE_SHELL}
   S:=TProcess.Create(Nil);
   S.Commandline:=ACompiler+' '+AOptions;
-  S.Options:=[poUsePipes,poNoConsole];
+  S.Options:=[poUsePipes];
   S.execute;
   Count:=s.output.read(buf,BufSize);
   S.Free;