From 9dfcd71dc1b065d35a9c2d039ed2a566ed3a2cbc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 21 Jan 2026 17:59:42 +0000 Subject: [PATCH] Bug 41678: Add warning log when SIPServer reaches max_servers capacity This enhancement adds logging to warn administrators when the SIP server reaches its configured maximum number of child processes. The warning is logged periodically (once per second) when the current child count equals or exceeds the max_servers configuration value. The implementation uses the pre_loop_hook to check capacity in the parent process and logs using the existing SIP logging system at WARNING level. --- C4/SIP/SIPServer.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index cd407fda738..6bf84f6ef8a 100644 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -656,6 +656,33 @@ sub get_timeout { } } +=head2 pre_loop_hook + +This hook is called before the main server loop starts. +We use it to periodically check if we're at max_servers capacity and log a warning. + +=cut + +sub pre_loop_hook { + my $self = shift; + + # Only check in the parent process + return unless $self->is_parent; + + # Limit checks to once per second to avoid excessive logging + state $last_check = 0; + return if time - $last_check < 1; + $last_check = time; + + my $server_props = $self->{server}; + my $max_servers = $server_props->{max_servers}; + my $current_children = scalar keys %{$server_props->{children} // {}}; + + if ($max_servers && $current_children >= $max_servers) { + siplog('LOG_WARNING', "SIPServer at maximum capacity: %d/%d child processes running", $current_children, $max_servers); + } +} + 1; __END__ -- 2.52.0