mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: listener: keep accept rate counters accurate under saturation
The test on l->nbconn forces to exit the loop before updating the freq counters, so the last session which reaches a listener's limit will not be accounted for in the session rate measurement. Let's move the test at the beginning of the loop and mark the listener as saturated on exit. This may be backported to 1.9 and 1.8.
This commit is contained in:
parent
12a718488a
commit
741b4d6b7a
@ -464,11 +464,6 @@ void listener_accept(int fd)
|
|||||||
if (HA_SPIN_TRYLOCK(LISTENER_LOCK, &l->lock))
|
if (HA_SPIN_TRYLOCK(LISTENER_LOCK, &l->lock))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (unlikely(l->nbconn >= l->maxconn)) {
|
|
||||||
listener_full(l);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(l->options & LI_O_UNLIMITED) && global.sps_lim) {
|
if (!(l->options & LI_O_UNLIMITED) && global.sps_lim) {
|
||||||
int max = freq_ctr_remain(&global.sess_per_sec, global.sps_lim, 0);
|
int max = freq_ctr_remain(&global.sess_per_sec, global.sps_lim, 0);
|
||||||
|
|
||||||
@ -527,7 +522,7 @@ void listener_accept(int fd)
|
|||||||
* worst case. If we fail due to system limits or temporary resource
|
* worst case. If we fail due to system limits or temporary resource
|
||||||
* shortage, we try again 100ms later in the worst case.
|
* shortage, we try again 100ms later in the worst case.
|
||||||
*/
|
*/
|
||||||
while (max_accept--) {
|
while (l->nbconn < l->maxconn && max_accept--) {
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
socklen_t laddr = sizeof(addr);
|
socklen_t laddr = sizeof(addr);
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
@ -647,11 +642,6 @@ void listener_accept(int fd)
|
|||||||
goto transient_error;
|
goto transient_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->nbconn >= l->maxconn) {
|
|
||||||
listener_full(l);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* increase the per-process number of cumulated connections */
|
/* increase the per-process number of cumulated connections */
|
||||||
if (!(l->options & LI_O_UNLIMITED)) {
|
if (!(l->options & LI_O_UNLIMITED)) {
|
||||||
count = update_freq_ctr(&global.sess_per_sec, 1);
|
count = update_freq_ctr(&global.sess_per_sec, 1);
|
||||||
@ -679,6 +669,9 @@ void listener_accept(int fd)
|
|||||||
limit_listener(l, &global_listener_queue);
|
limit_listener(l, &global_listener_queue);
|
||||||
task_schedule(global_listener_queue_task, tick_first(expire, global_listener_queue_task->expire));
|
task_schedule(global_listener_queue_task, tick_first(expire, global_listener_queue_task->expire));
|
||||||
end:
|
end:
|
||||||
|
if (l->nbconn >= l->maxconn)
|
||||||
|
listener_full(l);
|
||||||
|
|
||||||
HA_SPIN_UNLOCK(LISTENER_LOCK, &l->lock);
|
HA_SPIN_UNLOCK(LISTENER_LOCK, &l->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user