fix(gateway): fix http-api 500 issue if setting max_connections to infinity
This commit is contained in:
parent
c450a1784a
commit
8df7b1a1be
|
@ -304,7 +304,6 @@ do_listeners_cluster_status(Listeners) ->
|
|||
status => #{
|
||||
running => Running,
|
||||
current_connections => Curr,
|
||||
%% XXX: Since it is taken from raw-conf, it is possible a string
|
||||
max_connections => int(Max)
|
||||
}
|
||||
}
|
||||
|
@ -314,10 +313,15 @@ do_listeners_cluster_status(Listeners) ->
|
|||
Listeners
|
||||
).
|
||||
|
||||
int(infinity) ->
|
||||
infinity;
|
||||
int(<<"infinity">>) ->
|
||||
infinity;
|
||||
int(B) when is_binary(B) ->
|
||||
binary_to_integer(B);
|
||||
int(I) when is_integer(I) ->
|
||||
I.
|
||||
|
||||
aggregate_listener_status(NodeStatus) ->
|
||||
aggregate_listener_status(NodeStatus, 0, 0, undefined).
|
||||
|
||||
|
@ -330,11 +334,19 @@ aggregate_listener_status(
|
|||
CurrAcc,
|
||||
RunningAcc
|
||||
) ->
|
||||
NMaxAcc = plus_max_connections(MaxAcc, Max),
|
||||
NRunning = aggregate_running(Running, RunningAcc),
|
||||
aggregate_listener_status(T, MaxAcc + Max, Current + CurrAcc, NRunning);
|
||||
aggregate_listener_status(T, NMaxAcc, Current + CurrAcc, NRunning);
|
||||
aggregate_listener_status([], MaxAcc, CurrAcc, RunningAcc) ->
|
||||
{MaxAcc, CurrAcc, RunningAcc}.
|
||||
|
||||
plus_max_connections(_, infinity) ->
|
||||
infinity;
|
||||
plus_max_connections(infinity, _) ->
|
||||
infinity;
|
||||
plus_max_connections(A, B) when is_integer(A) andalso is_integer(B) ->
|
||||
A + B.
|
||||
|
||||
aggregate_running(R, R) -> R;
|
||||
aggregate_running(R, undefined) -> R;
|
||||
aggregate_running(_, _) -> inconsistent.
|
||||
|
|
|
@ -266,7 +266,7 @@ common_listener_opts() ->
|
|||
)},
|
||||
{max_connections,
|
||||
sc(
|
||||
integer(),
|
||||
hoconsc:union([infinity, pos_integer()]),
|
||||
#{
|
||||
default => 1024,
|
||||
desc => ?DESC(gateway_common_listener_max_connections)
|
||||
|
|
Loading…
Reference in New Issue