Ondrej Pokorny 4 лет назад
Родитель
Сommit
52c00037d3
2 измененных файлов с 11 добавлено и 4 удалено
  1. 4 1
      packages/fcl-net/src/ssockets.pp
  2. 7 3
      packages/fcl-web/src/base/fphttpserver.pp

+ 4 - 1
packages/fcl-net/src/ssockets.pp

@@ -497,7 +497,10 @@ begin
   IOTimeout := TimeOut;
   FHandler.Recv(B,0);
   Result := FHandler.FLastError=0;
-  IOTimeout := lTM;
+  try
+    IOTimeout := lTM;
+  except
+  end;
 end;
 
 Function TSocketStream.Read (Var Buffer; Count : Longint) : longint;

+ 7 - 3
packages/fcl-web/src/base/fphttpserver.pp

@@ -639,12 +639,12 @@ begin
   try
     try
       repeat
-        if Connection.EnableKeepAlive and Connection.KeepAlive
+        if not Terminated and Connection.EnableKeepAlive and Connection.KeepAlive
         and not Connection.Socket.CanRead(Connection.KeepAliveTimeout) then
           break;
 
         FConnection.HandleRequest;
-      until not (FConnection.EnableKeepAlive and FConnection.KeepAlive and (FConnection.Socket.LastError=0));
+      until not (Terminated and FConnection.EnableKeepAlive and FConnection.KeepAlive and (FConnection.Socket.LastError=0));
     finally
       FreeAndNil(FConnection);
       if Assigned(FThreadList) then
@@ -966,7 +966,11 @@ begin
     ThreadList:=FConnectionThreadList.LockList;
     try
       for I:= ThreadList.Count-1 downto 0 do
-        CloseSocket(TFPHTTPConnectionThread(ThreadList[I]).Connection.Socket.Handle);
+        try
+          CloseSocket(TFPHTTPConnectionThread(ThreadList[I]).Connection.Socket.Handle);
+        except
+          // ignore exceptions during CloseSocket
+        end
     finally
       FConnectionThreadList.UnlockList;
     end;