ames: fix incorrect handling of acks in |pack

This commit is contained in:
yosoyubik 2023-05-22 15:05:18 +02:00
parent a765954cee
commit 89da6d433b

View File

@ -3635,7 +3635,7 @@
=/ acc
:* found=`?`%.n
resends=*(list static-fragment)
metrics=metrics.state
metrics=metrics.state(num-live ~(wyt by live.state))
==
::
^+ [acc live=live.state]
@ -3647,14 +3647,15 @@
==
^- [new-val=(unit live-packet-val) stop=? _acc]
::
=/ gauge (ga metrics.acc ~(wyt by live.state))
=/ gauge (ga metrics.acc num-live.metrics.acc)
:: is this the acked packet?
::
?: =(key [message-num fragment-num])
:: delete acked packet, update metrics, and stop traversal
::
=. found.acc %.y
=. metrics.acc (on-ack:gauge -.val)
=. found.acc %.y
=. metrics.acc (on-ack:gauge -.val)
=. num-live.metrics.acc (dec num-live.metrics.acc)
[new-val=~ stop=%.y acc]
:: is this a duplicate ack?
::
@ -3686,6 +3687,9 @@
(pu-trace snd.veb |.("done {<num=message-num show:gauge>}"))
::
^+ [metrics=metrics.state live=live.state]
:: number of sent packets awaiting ack
::
=. num-live.metrics.state ~(wyt by live.state)
::
%^ (dip:packet-queue pump-metrics) live.state acc=metrics.state
|= $: metrics=pump-metrics
@ -3694,7 +3698,7 @@
==
^- [new-val=(unit live-packet-val) stop=? pump-metrics]
::
=/ gauge (ga metrics ~(wyt by live.state))
=/ gauge (ga metrics num-live.metrics)
:: if we get an out-of-order ack for a message, skip until it
::
?: (lth message-num.key message-num)
@ -3702,7 +3706,8 @@
:: if packet was from acked message, delete it and continue
::
?: =(message-num.key message-num)
[new-val=~ stop=%.n metrics=(on-ack:gauge -.val)]
=. metrics (on-ack:gauge -.val)
[new-val=~ stop=%.n metrics(num-live (dec num-live.metrics))]
:: we've gone past the acked message; we're done
::
[new-val=`val stop=%.y metrics]