Browse Source

* update lNet in fppkg to 0.5.6a

git-svn-id: trunk@8222 -
Almindor 18 years ago
parent
commit
7db1d24253

+ 6 - 2
utils/fppkg/lnet/lcommon.pp

@@ -53,10 +53,14 @@ const
   {$IFDEF UNIX}
   {$IFDEF UNIX}
   INVALID_SOCKET = -1;
   INVALID_SOCKET = -1;
   SOCKET_ERROR = -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;
     LMSG = MSG_NOSIGNAL;
     {$ELSE}
     {$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}
   {$ENDIF}
   {$ENDIF}
   { Default Values }
   { Default Values }

+ 15 - 9
utils/fppkg/lnet/lnet.pp

@@ -1,4 +1,4 @@
-{ lNet v0.5.5
+{ lNet v0.5.6
 
 
   CopyRight (C) 2004-2006 Ales Katona
   CopyRight (C) 2004-2006 Ales Katona
 
 
@@ -446,7 +446,7 @@ end;
 
 
 function TLSocket.Bail(const msg: string; const ernum: Integer): Boolean;
 function TLSocket.Bail(const msg: string; const ernum: Integer): Boolean;
 begin
 begin
-  Result  :=  False; // return the result for the caller
+  Result := False; // return the result for the caller
 
 
   Disconnect;
   Disconnect;
   LogError(msg, ernum);
   LogError(msg, ernum);
@@ -505,7 +505,8 @@ end;
 
 
 function TLSocket.Get(var aData; const aSize: Integer): Integer;
 function TLSocket.Get(var aData; const aSize: Integer): Integer;
 var
 var
-  AddressLength: Integer = SizeOf(FAddress);
+  AddressLength: Integer = SizeOf(FPeerAddress);
+  LastError: Longint;
 begin
 begin
   Result := 0;
   Result := 0;
   if CanReceive then begin
   if CanReceive then begin
@@ -516,10 +517,12 @@ begin
     if Result = 0 then
     if Result = 0 then
       Disconnect;
       Disconnect;
     if Result = SOCKET_ERROR then begin
     if Result = SOCKET_ERROR then begin
-      if IsBlockError(LSocketError) then begin
+      LastError := LSocketError;
+      if IsBlockError(LastError) then begin
         FCanReceive  :=  False;
         FCanReceive  :=  False;
         IgnoreRead  :=  False;
         IgnoreRead  :=  False;
-      end else Bail('Receive Error', LSocketError);
+      end else
+        Bail('Receive Error', LastError);
       Result := 0;
       Result := 0;
     end;
     end;
   end;
   end;
@@ -622,6 +625,8 @@ begin
 end;
 end;
 
 
 function TLSocket.Send(const aData; const aSize: Integer): Integer;
 function TLSocket.Send(const aData; const aSize: Integer): Integer;
+var
+  LastError: Longint;
 begin
 begin
   Result := 0;
   Result := 0;
   if not FServerSocket then begin
   if not FServerSocket then begin
@@ -633,11 +638,12 @@ begin
     if CanSend then begin
     if CanSend then begin
       Result := DoSend(aData, aSize);
       Result := DoSend(aData, aSize);
       if Result = SOCKET_ERROR then begin
       if Result = SOCKET_ERROR then begin
-        if IsBlockError(LSocketError) then begin
+        LastError := LSocketError;
+        if IsBlockError(LastError) then begin
           FCanSend := False;
           FCanSend := False;
           IgnoreWrite := False;
           IgnoreWrite := False;
         end else
         end else
-          Bail('Send error', LSocketError);
+          Bail('Send error', LastError);
         Result := 0;
         Result := 0;
       end;
       end;
     end;
     end;
@@ -849,7 +855,7 @@ procedure TLUdp.Disconnect;
 begin
 begin
   if Assigned(FRootSock) then begin
   if Assigned(FRootSock) then begin
     FRootSock.Disconnect;
     FRootSock.Disconnect;
-    FreeAndNil(FRootSock);
+    FRootSock := nil; // even if the old one exists, eventer takes care of it
   end;
   end;
 end;
 end;
 
 
@@ -1042,7 +1048,7 @@ begin
     FIterator := FRootSock;
     FIterator := FRootSock;
     RegisterWithEventer;
     RegisterWithEventer;
   end else begin
   end else begin
-    FreeAndNil(FRootSock);
+    FreeAndNil(FRootSock); // one possible use, since we're not in eventer yet
     FIterator := nil;
     FIterator := nil;
   end;
   end;
 end;
 end;

+ 14 - 25
utils/fppkg/lnet/sys/lepolleventer.inc

@@ -194,34 +194,23 @@ begin
 end;
 end;
 
 
 function BestEventerClass: TLEventerClass;
 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
 var
-  u: TUTSName;
-{$endif}
+  tmp: THandle;
 begin
 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;
       Result := TLEpollEventer;
-{$endif}
+    end else
+      Result := TLSelectEventer;
+  except
+    Result := TLSelectEventer;
+  end;
+  {$ELSE}
+  Result := TLSelectEventer;
+  {$ENDIF}
 end;
 end;
 
 
 {$endif} // Linux
 {$endif} // Linux

+ 4 - 0
utils/fppkg/lnet/sys/lkqueueeventer.inc

@@ -132,7 +132,11 @@ end;
 
 
 function BestEventerClass: TLEventerClass;
 function BestEventerClass: TLEventerClass;
 begin
 begin
+  {$IFNDEF FORCE_SELECT}
   Result := TLKQueueEventer;
   Result := TLKQueueEventer;
+  {$ELSE}
+  Result := TLSelectEventer;
+  {$ENDIF}
 end;
 end;
 
 
 {$endif} // BSD
 {$endif} // BSD