Skip to content

Commit 85bd80a

Browse files
committed
upstream: fix connection count when net.max_worker_connections is set (fix #10342)
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 9ab0b53 commit 85bd80a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/flb_upstream.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,15 +722,14 @@ struct flb_connection *flb_upstream_conn_get(struct flb_upstream *u)
722722
* - if keepalive is disabled, the connection is moved to 'drop_queue' then is
723723
* closed and destroyed.
724724
*
725-
* Based on the logic described above, to limit the number of total connections
726-
* in the worker, we only need to count the number of connections linked into
727-
* the 'busy_queue' list because if there are connections available 'av_queue' it
728-
* won't create a one.
725+
* To enforce a limit in the number of connections, we must count count all the
726+
* queues since they represent open connections.
729727
*/
730728

731-
/* Count the number of relevant connections */
732729
flb_stream_acquire_lock(&u->base, FLB_TRUE);
733-
total_connections = mk_list_size(&uq->busy_queue);
730+
total_connections = mk_list_size(&uq->busy_queue) +
731+
mk_list_size(&uq->av_queue) +
732+
mk_list_size(&uq->destroy_queue);
734733
flb_stream_release_lock(&u->base);
735734

736735
if (total_connections >= u->base.net.max_worker_connections) {

0 commit comments

Comments
 (0)