mORMot and Open Source friends
Check-in [cb774010da]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{5056} fixed Windows compilation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cb774010da164b93cbd8a6178d2b2990e72dd227
User & Date: ab 2019-02-22 13:10:08
Context
2019-02-22
13:13
{5057} new TAlgoCompress.Algo overloaded method check-in: df6510da89 user: ab tags: trunk
13:10
{5056} fixed Windows compilation check-in: cb774010da user: ab tags: trunk
09:21
{5055} tuned documentation about crc32c() to avoid confusion with plain zlib's crc() check-in: 282d870af7 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynCrtSock.pas.

1012
1013
1014
1015
1016
1017
1018

1019

1020
1021
1022
1023
1024
1025
1026
....
7121
7122
7123
7124
7125
7126
7127

7128
7129
7130
7131
7132
7133

7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
  TSynThreadPoolTHttpServer = class(TSynThreadPool)
  protected
    fServer: THttpServer;
    fHeaderErrors: integer;
    fHeaderProcessed: integer;
    fBodyProcessed: integer;
    fBodyOwnThreads: integer;

    function QueueLength: integer; override;

    // here aContext is a pointer(TSocket=THandle) value
    procedure Task(aCaller: TSynThread; aContext: Pointer); override;
    procedure TaskAbort(aContext: Pointer); override;
  public
    /// initialize a thread pool with the supplied number of threads
    // - Task() overridden method processs the HTTP request set by Push()
    // - up to 256 threads can be associated to a Thread Pool
................................................................................
constructor TSynThreadPoolTHttpServer.Create(Server: THttpServer; NumberOfThreads: Integer=32);
begin
  fServer := Server;
  fOnTerminate := fServer.fOnTerminate;
  inherited Create(NumberOfThreads{$ifndef USE_WINIOCP},{queuepending=}true{$endif});
end;


function TSynThreadPoolTHttpServer.QueueLength: integer;
begin
  if fServer=nil then
    result := 10000 else
    result := fServer.fHTTPQueueLength;
end;


procedure TSynThreadPoolTHttpServer.Task(aCaller: TSynThread; aContext: Pointer);
var ServerSock: THttpServerSocket;
    headertix: Int64;
begin
  if fServer.Terminated then
    exit;
  ServerSock := THttpServerSocket.Create(fServer);
  try
    ServerSock.InitRequest(TSocket(aContext));
    // get Header of incoming request in the thread pool
    headertix := fServer.HeaderRetrieveAbortDelay;
    if headertix>0 then
      inc(headertix,GetTickCount64);
    if ServerSock.GetRequest({withbody=}false,headertix) then begin
      InterlockedIncrement(fHeaderProcessed);
      // connection and header seem valid -> process request further
      if (fServer.ServerKeepAliveTimeOut>0) and
         (fServer.fInternalHttpServerRespList.Count<THREADPOOL_MAXWORKTHREADS) and
         (ServerSock.KeepAliveClient or
          (ServerSock.ContentLength>THREADPOOL_BIGBODYSIZE)) then begin






>

>







 







>






>













|







1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
....
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
  TSynThreadPoolTHttpServer = class(TSynThreadPool)
  protected
    fServer: THttpServer;
    fHeaderErrors: integer;
    fHeaderProcessed: integer;
    fBodyProcessed: integer;
    fBodyOwnThreads: integer;
    {$ifndef USE_WINIOCP}
    function QueueLength: integer; override;
    {$endif}
    // here aContext is a pointer(TSocket=THandle) value
    procedure Task(aCaller: TSynThread; aContext: Pointer); override;
    procedure TaskAbort(aContext: Pointer); override;
  public
    /// initialize a thread pool with the supplied number of threads
    // - Task() overridden method processs the HTTP request set by Push()
    // - up to 256 threads can be associated to a Thread Pool
................................................................................
constructor TSynThreadPoolTHttpServer.Create(Server: THttpServer; NumberOfThreads: Integer=32);
begin
  fServer := Server;
  fOnTerminate := fServer.fOnTerminate;
  inherited Create(NumberOfThreads{$ifndef USE_WINIOCP},{queuepending=}true{$endif});
end;

{$ifndef USE_WINIOCP}
function TSynThreadPoolTHttpServer.QueueLength: integer;
begin
  if fServer=nil then
    result := 10000 else
    result := fServer.fHTTPQueueLength;
end;
{$endif USE_WINIOCP}

procedure TSynThreadPoolTHttpServer.Task(aCaller: TSynThread; aContext: Pointer);
var ServerSock: THttpServerSocket;
    headertix: Int64;
begin
  if fServer.Terminated then
    exit;
  ServerSock := THttpServerSocket.Create(fServer);
  try
    ServerSock.InitRequest(TSocket(aContext));
    // get Header of incoming request in the thread pool
    headertix := fServer.HeaderRetrieveAbortDelay;
    if headertix>0 then
      headertix := headertix+GetTickCount64;
    if ServerSock.GetRequest({withbody=}false,headertix) then begin
      InterlockedIncrement(fHeaderProcessed);
      // connection and header seem valid -> process request further
      if (fServer.ServerKeepAliveTimeOut>0) and
         (fServer.fInternalHttpServerRespList.Count<THREADPOOL_MAXWORKTHREADS) and
         (ServerSock.KeepAliveClient or
          (ServerSock.ContentLength>THREADPOOL_BIGBODYSIZE)) then begin

Changes to SynopseCommit.inc.

1
'1.18.5055'
|
1
'1.18.5056'