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

Reduce contention on protected-int thread_count

We can capture the new value upon atomic-decrement, use it
parent 76acaac0
No related branches found
No related tags found
No related merge requests found
...@@ -816,11 +816,12 @@ static void thread_up(bool setuid) ...@@ -816,11 +816,12 @@ static void thread_up(bool setuid)
startup->thread_up(startup->cbdata, true, setuid); startup->thread_up(startup->cbdata, true, setuid);
} }
static void thread_down(void) static uint32_t thread_down(void)
{ {
(void)protected_uint32_adjust(&thread_count, -1); uint32_t count = protected_uint32_adjust(&thread_count, -1);
if (startup != NULL && startup->thread_up != NULL) if (startup != NULL && startup->thread_up != NULL)
startup->thread_up(startup->cbdata, false, false); startup->thread_up(startup->cbdata, false, false);
return count;
} }
/*********************************************************************/ /*********************************************************************/
...@@ -7077,13 +7078,13 @@ void http_session_thread(void* arg) ...@@ -7077,13 +7078,13 @@ void http_session_thread(void* arg)
update_clients(); update_clients();
client_off(socket); client_off(socket);
thread_down(); uint32_t threads_remain = thread_down();
if (startup->index_file_name == NULL || startup->cgi_ext == NULL) if (startup->index_file_name == NULL || startup->cgi_ext == NULL)
lprintf(LOG_DEBUG, "%04d !!! ALL YOUR BASE ARE BELONG TO US !!!", socket); lprintf(LOG_DEBUG, "%04d !!! ALL YOUR BASE ARE BELONG TO US !!!", socket);
lprintf(LOG_INFO, "%04d %s [%s] Session thread terminated (%u clients and %u threads remain, %lu served, %u concurrently)" lprintf(LOG_INFO, "%04d %s [%s] Session thread terminated (%u clients and %u threads remain, %lu served, %u concurrently)"
, socket, session.client.protocol, session.host_ip, clients_remain, protected_uint32_value(thread_count), ++served, client_highwater); , socket, session.client.protocol, session.host_ip, clients_remain, threads_remain, ++served, client_highwater);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment