Skip to content
Snippets Groups Projects
Commit b881935a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Track the active client "highwater mark" (highest number of concurrent clients)

Could be useful for knowing if you need to increase MaxClients for typical
usage.
parent 6aade458
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1574 passed
......@@ -102,7 +102,7 @@ static scfg_t scfg;
static volatile BOOL http_logging_thread_running=FALSE;
static protected_uint32_t active_clients;
static protected_uint32_t thread_count;
static volatile ulong sockets=0;
static volatile ulong client_highwater=0;
static volatile BOOL terminate_server=FALSE;
static volatile BOOL terminated=FALSE;
static volatile BOOL terminate_http_logging_thread=FALSE;
......@@ -957,15 +957,12 @@ static void open_socket(SOCKET sock, void *cbdata)
strcpy(afa.af_name, "httpready");
setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
#endif
sockets++;
}
static void close_socket_cb(SOCKET sock, void *cbdata)
{
if(startup!=NULL && startup->socket_open!=NULL)
startup->socket_open(startup->cbdata,FALSE);
sockets--;
}
static int close_socket(SOCKET *sock)
......@@ -993,7 +990,6 @@ static int close_socket(SOCKET *sock)
if(startup!=NULL && startup->socket_open!=NULL) {
startup->socket_open(startup->cbdata,FALSE);
}
sockets--;
if(result!=0) {
if(ERROR_VALUE!=ENOTSOCK)
lprintf(LOG_WARNING,"%04d !ERROR %d closing socket",*sock, ERROR_VALUE);
......@@ -6768,7 +6764,8 @@ static void cleanup(int code)
thread_down();
status("Down");
if(terminate_server || code)
lprintf(LOG_INFO,"#### Web Server thread terminated (%lu clients served)", served);
lprintf(LOG_INFO,"#### Web Server thread terminated (%lu clients served, %lu concurrently)"
,served, client_highwater);
if(startup!=NULL && startup->terminated!=NULL)
startup->terminated(startup->cbdata,code);
}
......@@ -6921,6 +6918,7 @@ void DLLCALL web_server(void* arg)
char *ssl_estr;
int lvl;
int i;
ulong count;
startup=(web_startup_t*)arg;
......@@ -7210,6 +7208,11 @@ void DLLCALL web_server(void* arg)
continue;
}
if((count = protected_uint32_value(active_clients)) > client_highwater) {
client_highwater = count;
lprintf(LOG_NOTICE, "%04d New active client highwater mark: %lu"
,client_socket, client_highwater);
}
if(startup->max_clients && protected_uint32_value(active_clients)>=startup->max_clients) {
lprintf(LOG_WARNING,"%04d !MAXIMUM CLIENTS (%d) reached, access denied"
,client_socket, startup->max_clients);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment