X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/1e45a1f0bf2ab89879ac9855b76ddfed1c406c3f..170e475daffeb198914a020e26afaf803a6f9608:/lcore.pas

diff --git a/lcore.pas b/lcore.pas
index 99fbe98..727ca1c 100755
--- a/lcore.pas
+++ b/lcore.pas
@@ -35,8 +35,13 @@ interface
 
 
   const
-    {for IPv6 it is 1440: 1500 - IP header (40) - TCP/UDP header (20). for ipv4 it is 1460}
-    packetbasesize = 1440;
+    {how this number is made up:
+    - ethernet: MTU 1500
+    - be safe for either "ethernet v1" or "PPPoE", both take 8 bytes
+    - IPv6 header: 40 bytes (IPv4 is 20)
+    - TCP/UDP header: 20 bytes
+    }
+    packetbasesize = 1432;
     receivebufsize=packetbasesize*8;
 
   var
@@ -400,6 +405,9 @@ end;
 procedure tlasio.internalclose(error:word);
 begin
   if (state<>wsclosed) and (state<>wsinvalidstate) then begin
+    // -2 is a special indication that we should just exist silently
+    // (used for connect failure handling when socket creation fails)
+    if (fdhandlein = -2) and (fdhandleout = -2) then exit;
     if (fdhandlein < 0) or (fdhandleout < 0) then raise exception.create('internalclose called with invalid fd handles');
     eventcore.rmasterclr(fdhandlein);//fd_clr(fdhandlein,fdsrmaster);
     eventcore.wmasterclr(fdhandleout);//fd_clr(fdhandleout,fdswmaster);
@@ -568,7 +576,16 @@ begin
           internalclose(0);
 
         end else begin
-          internalclose({$ifdef win32}getlasterror{$else}linuxerror{$endif});
+          {$ifdef win32}
+          if getlasterror=WSAEWOULDBLOCK then begin
+            //the asynchronous nature of windows messages means we sometimes
+            //get here with the buffer full
+            //so do nothing in that case
+          end else
+          {$endif}
+          begin
+            internalclose({$ifdef win32}getlasterror{$else}linuxerror{$endif});
+          end  
         end;
       end;