File tree 1 file changed +18
-13
lines changed
1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -660,26 +660,31 @@ static int enable_listensocks(void)
660
660
return 1 ;
661
661
}
662
662
663
- static APR_INLINE apr_uint32_t listeners_disabled (void )
663
+ static APR_INLINE int listeners_disabled (void )
664
664
{
665
- return apr_atomic_read32 (& listensocks_disabled );
665
+ return apr_atomic_read32 (& listensocks_disabled ) != 0 ;
666
666
}
667
667
668
- static APR_INLINE int connections_above_limit ( int * busy )
668
+ static APR_INLINE apr_uint32_t u32_min ( apr_uint32_t u1 , apr_uint32_t u2 )
669
669
{
670
- apr_uint32_t i_count = ap_queue_info_num_idlers (worker_queue_info );
671
- if (i_count > 0 ) {
672
- apr_uint32_t c_count = apr_atomic_read32 (& connection_count );
673
- apr_uint32_t l_count = apr_atomic_read32 (& lingering_count );
674
- if (c_count <= l_count
675
- /* Off by 'listeners_disabled()' to avoid flip flop */
676
- || c_count - l_count < (apr_uint32_t )threads_per_child +
677
- (i_count - listeners_disabled ()) *
678
- async_factor ) {
670
+ return (u1 < u2 ) ? u1 : u2 ;
671
+ }
672
+
673
+ static int connections_above_limit (int * busy )
674
+ {
675
+ #ifndef LISTEN_OFF_RATE
676
+ #define LISTEN_OFF_RATE 4u
677
+ #endif
678
+ apr_uint32_t t_p_c = (apr_uint32_t )threads_per_child ;
679
+ apr_uint32_t i_num = ap_queue_info_num_idlers (worker_queue_info );
680
+ apr_uint32_t i_min = listeners_disabled () ? t_p_c / LISTEN_OFF_RATE : 0 ;
681
+ if (i_num > i_min ) { /* amortize disable=>enable_listensocks() switch */
682
+ apr_uint32_t t_num = t_p_c + i_num * async_factor ;
683
+ if (apr_atomic_read32 (pending_q -> total ) <= t_num ) {
679
684
return 0 ;
680
685
}
681
686
}
682
- else if (busy ) {
687
+ else if (busy && ! i_num ) {
683
688
* busy = 1 ;
684
689
}
685
690
return 1 ;
You can’t perform that action at this time.
0 commit comments