Skip to content
Permalink
Browse files

new THttpServer.ServerConnectionActive property

  • Loading branch information
Arnaud Bouchez
Arnaud Bouchez committed Jan 23, 2020
1 parent 8a42579 commit 8883448fa178a24be18c708ce036f0c26ac89841
Showing with 15 additions and 9 deletions.
  1. +13 −7 SynCrtSock.pas
  2. +1 −1 SynFPCSock.pas
  3. +1 −1 SynopseCommit.inc
@@ -1101,14 +1101,13 @@ THttpServerGeneric = class;
// - OutContent/OutContentType/OutCustomHeader are output parameters
THttpServerRequest = class
protected
fURL, fMethod, fInHeaders, fInContent, fInContentType: SockString;
fURL, fMethod, fInHeaders, fInContent, fInContentType, fAuthenticatedUser,
fOutContent, fOutContentType, fOutCustomHeaders: SockString;
fServer: THttpServerGeneric;
fConnectionID: Int64;
fConnectionThread: TSynThread;
fUseSSL: boolean;
fAuthenticationStatus: THttpServerRequestAuthentication;
fAuthenticatedUser: SockString;
{$ifdef MSWINDOWS}
fHttpApiRequest: Pointer;
{$endif}
@@ -1970,7 +1969,8 @@ THttpServer = class(THttpServerGeneric)
fHeaderRetrieveAbortDelay: integer;
fThreadPool: TSynThreadPoolTHttpServer;
fInternalHttpServerRespList: TList;
fServerConnectionCount: cardinal;
fServerConnectionCount: integer;
fServerConnectionActive: integer;
fServerKeepAliveTimeOut: cardinal;
fTCPPrefix: SockString;
fSock: TCrtSocket;
@@ -2037,9 +2037,12 @@ THttpServer = class(THttpServerGeneric)
// - see also NginxSendFileFrom() method
property OnSendFile: TOnHttpServerSendFile read fOnSendFile write fOnSendFile;
published
/// will contain the current number of connections to the server
property ServerConnectionActive: integer
read fServerConnectionActive write fServerConnectionActive;
/// will contain the total number of connections to the server
// - it's the global count since the server started
property ServerConnectionCount: cardinal
property ServerConnectionCount: integer
read fServerConnectionCount write fServerConnectionCount;
/// time, in milliseconds, for the HTTP/1.1 connections to be kept alive
// - default is 3000 ms
@@ -4551,6 +4554,8 @@ procedure RetrieveMacAddresses;
until p = nil;
end;
{$endif MSWINDOWS}
{ TODO : RetrieveMacAddresses() for BSD
see e.g. https://gist.github.com/OrangeTide/909204 }
finally
LeaveCriticalSection(SynSockCS);
end;
@@ -6344,12 +6349,13 @@ procedure THttpServer.Execute;

procedure THttpServer.OnConnect;
begin
inc(fServerConnectionCount);
InterLockedIncrement(fServerConnectionCount);
InterLockedIncrement(fServerConnectionActive);
end;

procedure THttpServer.OnDisconnect;
begin
// nothing to do by default
InterLockedDecrement(fServerConnectionActive);
end;

procedure THttpServer.Process(ClientSock: THttpServerSocket;
@@ -6861,7 +6867,7 @@ procedure THttpSocket.HeaderSetText(const aText, aForcedContentType: SockString)
function THttpSocket.HeaderGetText(const aRemoteIP: SockString): SockString;
var i,L,Lip,n: integer;
P: PAnsiChar;
begin // faster than for i := 0 to Count-1 do result := result+Headers[i]+#13#10
begin // faster than for .. do result := result+Headers[i]+#13#10
if fHeaderText='' then begin
n := length(Headers);
L := n*2; // #13#10 size
@@ -1164,7 +1164,7 @@ procedure ResolveNameToIP(const Name: AnsiString; Family, SockProtocol, SockType
x := 1;
end else
x := Resolvename(name,a4) else
x := 1;
x := 1;
for n := 1 to x do
IpList.Add(netaddrToStr(a4[n]));
end;
@@ -1 +1 @@
'1.18.5586'
'1.18.5587'

0 comments on commit 8883448

Please sign in to comment.
You can’t perform that action at this time.