fix(v4.0.0): what a node passes on waits with it, offered -- a relay is not held by a stuck node
Found after the last commit: a message being passed on toward a node that was stuck held the node passing it on in the wait, taking in what came but serving none of it; text typed for a stuck node left Hera deaf. And a node that had done text for a sender that then stuck waited on it to give its answer. A node with nothing to do now deals first with what is for itself; then offers at once the first message for each port and each refusal owed, and sleeps in the wait. What is taken is written and done with; the rest stays with the messages waiting, in order. How text ended is put with the messages waiting, not written from (FINISH). The stack is kept as shallow between lines as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
482cc75faf
commit
1c720ab2c7
+26
-23
@@ -182,7 +182,7 @@ header CMOVE
|
||||
\ messages in so as to be free to write, where it cannot begin a message
|
||||
\ of its own: so it notes what it owes, (OWE), in the eight pairs at
|
||||
\ (OWED) -- whom it is owed to, and the node the message was for -- and
|
||||
\ sends it when it next has nothing else to do, (PAY). With eight owed
|
||||
\ sends it when it next has nothing else to do, (PAY-SET). With eight owed
|
||||
\ already, one more is let go and counted. Nothing is owed for a NACK or
|
||||
\ for a GONE, type 5: there is no NACK for a NACK. The last 36 cells of
|
||||
\ the messages waiting are kept for those two types, so that ordinary
|
||||
@@ -303,13 +303,14 @@ header CMOVE
|
||||
16 !b 0 !b 0 !b ; \ how many nodes may pass it on (the TTL: MESH.md 7b); ACL tag; sequence
|
||||
|
||||
\ PAYING WHAT IS OWED (MESH.md 7c.3). Every refusal owed is offered at
|
||||
\ once, each on the port it goes by, one to a port, and the node sleeps in
|
||||
\ the wait: so one owed to a node that is stuck does not keep back one
|
||||
\ owed to a node that waits for it, and the node takes in whatever is
|
||||
\ written to it meanwhile. One there is no way for, or whose way is a
|
||||
\ once, each on the port it goes by, one to a port, with whatever the node
|
||||
\ has to pass on (quit.v4, (IDLE)), and the node sleeps in the wait: so
|
||||
\ one owed to a node that is stuck does not keep back one owed to a node
|
||||
\ that waits for it, and the node takes in whatever is written to it
|
||||
\ meanwhile. One there is no way for, or whose way is a
|
||||
\ port with nothing on it, is let go and counted first. (PAY-K) has a
|
||||
\ cell for each port: which refusal is offered there, counted from 1; 0,
|
||||
\ none.
|
||||
\ none; -1, a message being passed on.
|
||||
|
||||
\ ( k -- ) the k-th refusal owed is done with: the last takes its place
|
||||
: (PAID)
|
||||
@@ -327,30 +328,32 @@ header CMOVE
|
||||
|
||||
\ ( k -- ) offer the k-th refusal owed on its port, if nothing is there yet
|
||||
: (PAY-OFFER)
|
||||
dup 2* (OWED) + a! @ \ k to
|
||||
dup (PORT-FOR) (PORT) - \ k to n the port, by its number
|
||||
dup push 2* (OWED) + a! @ \ to R: k (the stack is kept shallow: this runs between lines)
|
||||
dup (PORT-FOR) (PORT) - \ to n the port, by its number
|
||||
dup (PAY-K) + a! @ if FREE
|
||||
drop drop drop drop ;
|
||||
drop drop drop pop drop ;
|
||||
FREE: drop
|
||||
dup push (OFFER) + a! ! \ k the message's first word, whom it is to
|
||||
1 + pop (PAY-K) + a! ! ;
|
||||
dup push (OFFER) + a! ! \ the message's first word, whom it is to
|
||||
pop pop 1 + SWAP (PAY-K) + a! ! ;
|
||||
|
||||
\ ( -- flag ) offer every refusal this node owes and wait once: if one
|
||||
\ is taken its other words are written and it is done with. Zero if
|
||||
\ nothing is owed, and then nothing was waited for.
|
||||
: (PAY)
|
||||
\ ( -- ) let go every refusal owed that cannot be sent; no port has an
|
||||
\ offer; then offer each that is left on its port
|
||||
: (PAY-SET)
|
||||
(OWED#) a! @ if NONE
|
||||
-1 + FOR pop dup push (PAY-DROP) NEXT
|
||||
(OWED#) a! @ if NONE
|
||||
(PAY-K) a! PORTS-1 FOR 0 !+ NEXT
|
||||
-1 + FOR pop dup push (PAY-OFFER) NEXT
|
||||
(OFFERS) if CAME
|
||||
drop (GATE-PORT) a! @ (PORT) - (PAY-K) + a! @ -1 + \ k: the one that was taken
|
||||
jump CLEAR
|
||||
NONE: drop
|
||||
CLEAR: (PAY-K) a! PORTS-1 FOR 0 !+ NEXT
|
||||
(OWED#) a! @ if NONE2
|
||||
-1 + FOR pop dup push (PAY-OFFER) NEXT ;
|
||||
NONE2: drop ;
|
||||
|
||||
\ ( k -- ) the offer of the k-th refusal owed was taken, and B is at the
|
||||
\ port: its other words are written, and it is done with
|
||||
: (PAY-GO)
|
||||
dup 2* (OWED) + 1 + a! @ \ k about
|
||||
4 (HDR) 4 !b !b \ from, type 4; four characters; about
|
||||
(PAID) -1 ;
|
||||
CAME: drop -1 ;
|
||||
NONE: drop 0 ;
|
||||
jump (PAID)
|
||||
|
||||
\ ( -- ) send what has been printed, to where (PRINT-TO) says, by the port
|
||||
\ (PRINT-PORT): its length, then its characters, four to a word, the first
|
||||
|
||||
Reference in New Issue
Block a user