> Am 20.06.2022 um 09:08 schrieb Ruediger Pluem <rpl...@apache.org>:
>
>
>
> On 6/17/22 11:24 AM, ic...@apache.org wrote:
>> Author: icing
>> Date: Fri Jun 17 09:24:57 2022
>> New Revision: 1902005
>>
>> URL: http://svn.apache.org/viewvc?rev=1902005&view=rev
>> Log:
>> *) mod_http2: new implementation of h2 worker pool.
>> - O(1) cost at registration of connection processing producers
>> - no limit on registered producers
>> - join of ongoing work on unregister
>> - callbacks to unlink dependencies into other h2 code
>> - memory cleanup on workers deactivation (on idle timeouts)
>> - idle_limit as apr_time_t instead of seconds
>>
>>
>> Modified:
>> httpd/httpd/trunk/modules/http2/h2_c1.c
>> httpd/httpd/trunk/modules/http2/h2_config.c
>> httpd/httpd/trunk/modules/http2/h2_config.h
>> httpd/httpd/trunk/modules/http2/h2_mplx.c
>> httpd/httpd/trunk/modules/http2/h2_mplx.h
>> httpd/httpd/trunk/modules/http2/h2_workers.c
>> httpd/httpd/trunk/modules/http2/h2_workers.h
>> httpd/httpd/trunk/modules/http2/mod_http2.c
>
>> Modified: httpd/httpd/trunk/modules/http2/h2_workers.c
>> URL:
>> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_workers.c?rev=1902005&r1=1902004&r2=1902005&view=diff
>> ==============================================================================
>> --- httpd/httpd/trunk/modules/http2/h2_workers.c (original)
>> +++ httpd/httpd/trunk/modules/http2/h2_workers.c Fri Jun 17 09:24:57 2022
>
>>
>> @@ -347,37 +367,47 @@ static apr_status_t workers_pool_cleanup
>> int n, wait_sec = 5;
>
> Should n be initialized to 0 to avoid
>
> ‘n’ may be used uninitialized in this function
>
> ?
Yes. good catch. Fixed in r1902082
>>
>> ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s,
>> - "h2_workers: cleanup %d workers idling",
>> - (int)apr_atomic_read32(&workers->worker_count));
>> - workers_abort_idle(workers);
>> + "h2_workers: cleanup %d workers (%d idle)",
>> + workers->active_slots, workers->idle_slots);
>> + apr_thread_mutex_lock(workers->lock);
>> + workers->shutdown = 1;
>> + workers->aborted = 1;
>> + wake_all_idles(workers);
>> + apr_thread_mutex_unlock(workers->lock);
>>
>> /* wait for all the workers to become zombies and join them.
>> * this gets called after the mpm shuts down and all connections
>> * have either been handled (graceful) or we are forced exiting
>> * (ungrateful). Either way, we show limited patience. */
>> - apr_thread_mutex_lock(workers->lock);
>> end = apr_time_now() + apr_time_from_sec(wait_sec);
>> - while ((n = apr_atomic_read32(&workers->worker_count)) > 0
>> - && apr_time_now() < end) {
>> + while (apr_time_now() < end) {
>> + apr_thread_mutex_lock(workers->lock);
>> + if (!(n = workers->active_slots)) {
>> + apr_thread_mutex_unlock(workers->lock);
>> + break;
>> + }
>> + wake_all_idles(workers);
>> rv = apr_thread_cond_timedwait(workers->all_done, workers->lock,
>> timeout);
>> + apr_thread_mutex_unlock(workers->lock);
>> +
>> if (APR_TIMEUP == rv) {
>> ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s,
>> - APLOGNO(10290) "h2_workers: waiting for idle
>> workers to close, "
>> - "still seeing %d workers living",
>> - apr_atomic_read32(&workers->worker_count));
>> - continue;
>> + APLOGNO(10290) "h2_workers: waiting for workers to
>> close, "
>> + "still seeing %d workers (%d idle) living",
>> + workers->active_slots, workers->idle_slots);
>> }
>> }
>> if (n) {
>> ap_log_error(APLOG_MARK, APLOG_WARNING, 0, workers->s,
>> - APLOGNO(10291) "h2_workers: cleanup, %d idle workers "
>> + APLOGNO(10291) "h2_workers: cleanup, %d workers (%d
>> idle) "
>> "did not exit after %d seconds.",
>> - n, wait_sec);
>> + n, workers->idle_slots, wait_sec);
>> }
>> - apr_thread_mutex_unlock(workers->lock);
>> ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s,
>> "h2_workers: cleanup all workers terminated");
>> + apr_thread_mutex_lock(workers->lock);
>> join_zombies(workers);
>> + apr_thread_mutex_unlock(workers->lock);
>> ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, workers->s,
>> "h2_workers: cleanup zombie workers joined");
>>
>
>
> Regards
>
> Rüdiger