Browse Source

+ implement support for terminating a HTTPSys web service handler that's blocking inside WaitForRequest

Sven Barth 3 years ago
parent
commit
86d4820760
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/fcl-web/src/base/custhttpsys.pp

+ 7 - 1
packages/fcl-web/src/base/custhttpsys.pp

@@ -653,7 +653,9 @@ begin
         fBuffer := GetMem(fBufferSize);
       end;
     until res <> ERROR_MORE_DATA;
-    if res <> NO_ERROR then
+    if res = ERROR_OPERATION_ABORTED then
+      Break
+    else if res <> NO_ERROR then
       DoError(SErrReceiveRequest, [res])
     else begin
       ProcessRequest(fBuffer, readsize, aRequest, aResponse);
@@ -688,6 +690,10 @@ end;
 
 procedure THTTPSysHandler.Terminate;
 begin
+  if fHandle <> INVALID_HANDLE_VALUE then begin
+    HttpCloseRequestQueue(fHandle);
+    fHandle := INVALID_HANDLE_VALUE;
+  end;
   inherited Terminate;
 end;