From 2553573be0de8a189d133898ae58cac6a61aff86 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 17 May 2022 07:11:09 +0200 Subject: [PATCH 1/2] ames: start drainage timer if regressed from adult This accounts for a possible race condition where ames expects a response, but regresses into the larval state. Upon receiving the $sign on +take, we would remain stuck as a larva. Now we check that we have enough information to re-evolve and then start a /larval timer to begin draining the queue. --- bin/solid.pill | 4 +-- pkg/arvo/sys/vane/ames.hoon | 55 ++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 500e2243f..8ab816f79 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:655bac06453b7d26ed0549576577dae1adc0fff3fefe202065cca752ff74e4e2 -size 9640752 +oid sha256:afe650a1583104e57bc83d7a0804405661b2e7a53e0673694ad53522b8894d79 +size 9526886 diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 8e7145ff9..0d6cb5552 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -784,6 +784,13 @@ |= [now=@da eny=@ rof=roof] =* larval-gate . =* adult-core (adult-gate +<) +=< |% + ++ call ^call + ++ load ^load + ++ scry ^scry + ++ stay ^stay + ++ take ^take + -- |% :: +call: handle request $task :: @@ -796,17 +803,8 @@ ?^ dud ~|(%ames-larval-call-dud (mean tang.u.dud)) :: - =/ update-ready=? - ?& ?=(^ cached-state) - ?=(~ queued-events) - == - ?: update-ready - =. ames-state.adult-gate - ?> ?=(^ cached-state) - (state-5-to-6:load:adult-core +.u.cached-state) - =. cached-state ~ - ~> %slog.1^leaf/"ames: metamorphosis reload" - [~ adult-gate] + ?: &(?=(^ cached-state) ?=(~ queued-events)) + (molt ~) :: %born: set .unix-duct and start draining .queued-events :: ?: ?=(%born -.task) @@ -836,11 +834,17 @@ ~|(%ames-larval-take-dud (mean tang.u.dud)) :: enqueue event if not a larval drainage timer :: + =? queued-events !=(/larva wire) + (~(put to queued-events) %take wire duct sign) + :: start drainage timer if have regressed from adult ames + :: + ?: ?& !=(/larva wire) + ?=(^ cached-state) + == + [[duct %pass /larva %b %wait now]~ larval-gate] :: XX what to do with errors? :: - ?. =(/larva wire) - =. queued-events (~(put to queued-events) %take wire duct sign) - [~ larval-gate] + ?. =(/larva wire) [~ larval-gate] :: larval event drainage timer; pop and process a queued event :: ?. ?=([%behn %wake *] sign) @@ -879,20 +883,10 @@ %call (call:adult-core [duct ~ wrapped-task]:+.first-event) %take (take:adult-core [wire duct ~ sign]:+.first-event) == - =/ update-ready=? - ?& ?=(^ cached-state) - ?=(~ queued-events) - == - ?: update-ready - =. ames-state.adult-gate - ?> ?=(^ cached-state) - (state-5-to-6:load:adult-core +.u.cached-state) - =. cached-state ~ - ~> %slog.1^leaf/"ames: metamorphosis reload" - [moves adult-gate] :: .queued-events has been cleared; metamorphose :: ?~ queued-events + ?: ?=(^ cached-state) (molt moves) ~> %slog.0^leaf/"ames: metamorphosis" [moves adult-gate] :: set timer to drain next event @@ -952,6 +946,17 @@ =. adult-gate (load:adult-core %6 state.old) larval-gate == + :: +molt: re-evolve to adult-ames + :: + ++ molt + |= moves=(list move) + ^- (quip move _adult-gate) + =. ames-state.adult-gate + ?> ?=(^ cached-state) + (state-5-to-6:load:adult-core +.u.cached-state) + =. cached-state ~ + ~> %slog.1^leaf/"ames: metamorphosis reload" + [~ adult-gate] -- :: adult ames, after metamorphosis from larva :: From 4dae3ae3e2734b5972aa127cc3a8cdc406fa6fa6 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Tue, 17 May 2022 07:49:15 +0200 Subject: [PATCH 2/2] ames: indent --- pkg/arvo/sys/vane/ames.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 0d6cb5552..90cd58a13 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -784,7 +784,7 @@ |= [now=@da eny=@ rof=roof] =* larval-gate . =* adult-core (adult-gate +<) -=< |% + =< |% ++ call ^call ++ load ^load ++ scry ^scry