Merge pull request #6749 from urbit/m/avoid-mideyre-crash

eyre: avoid +got'ing a channel that doesn't exist
This commit is contained in:
Pyry Kovanen 2023-08-14 18:11:52 +03:00 committed by GitHub
commit c7173781f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 29 deletions

View File

@ -2433,7 +2433,7 @@
^- move ^- move
%- (trace 1 |.("subscribing to {<app>} on {<path>}")) %- (trace 1 |.("subscribing to {<app>} on {<path>}"))
%+ deal-as %+ deal-as
(subscription-wire channel-id request-id ship app) (subscription-wire channel-id request-id from ship app)
[from ship app %watch path] [from ship app %watch path]
:: ::
=. session.channel-state.state =. session.channel-state.state
@ -2472,7 +2472,7 @@
=, u.maybe-subscription =, u.maybe-subscription
%- (trace 1 |.("leaving subscription to {<app>}")) %- (trace 1 |.("leaving subscription to {<app>}"))
%+ deal-as %+ deal-as
(subscription-wire channel-id subscription-id ship app) (subscription-wire channel-id subscription-id from ship app)
[from ship app %leave ~] [from ship app %leave ~]
:: ::
=. session.channel-state.state =. session.channel-state.state
@ -2508,7 +2508,7 @@
:: ::
?. ?& !(~(has by session.channel-state.state) channel-id) ?. ?& !(~(has by session.channel-state.state) channel-id)
?=(?(%fact %watch-ack) -.sign) ?=(?(%fact %watch-ack) -.sign)
?=([@ @ ~] extra) ?=([@ @ *] extra)
== ==
(emit-event channel-id request-id sign) (emit-event channel-id request-id sign)
=/ =ship (slav %p i.extra) =/ =ship (slav %p i.extra)
@ -2518,10 +2518,14 @@
:_ state :_ state
:_ ~ :_ ~
^- move ^- move
=/ as=^ship
?+ t.t.extra ~|([%strange-wire extra] !!)
~ our :: old-style wire
[@ ~] (slav %p i.t.t.extra)
==
%+ deal-as %+ deal-as
(subscription-wire channel-id request-id ship app) (subscription-wire channel-id request-id as ship app)
=+ id=identity:(~(got by session.channel-state.state) channel-id) [as ship app %leave ~]
[id ship app %leave ~]
:: +emit-event: records an event occurred, possibly sending to client :: +emit-event: records an event occurred, possibly sending to client
:: ::
:: When an event occurs, we need to record it, even if we immediately :: When an event occurs, we need to record it, even if we immediately
@ -2623,7 +2627,7 @@
=+ (~(got by subscriptions.u.channel) request-id) =+ (~(got by subscriptions.u.channel) request-id)
%- (trace 1 |.("leaving subscription to {<app>}")) %- (trace 1 |.("leaving subscription to {<app>}"))
%+ deal-as %+ deal-as
(subscription-wire channel-id request-id ship app) (subscription-wire channel-id request-id identity.u.channel ship app)
[identity.u.channel ship app %leave ~] [identity.u.channel ship app %leave ~]
:: update channel state to reflect the %kick :: update channel state to reflect the %kick
:: ::
@ -2834,7 +2838,7 @@
^- move ^- move
%- (trace 1 |.("{<channel-id>} leaving subscription to {<app>}")) %- (trace 1 |.("{<channel-id>} leaving subscription to {<app>}"))
%+ deal-as %+ deal-as
(subscription-wire channel-id request-id ship app) (subscription-wire channel-id request-id identity.session ship app)
[identity.session ship app %leave ~] [identity.session ship app %leave ~]
-- --
:: +handle-gall-error: a call to +poke-http-response resulted in a %coup :: +handle-gall-error: a call to +poke-http-response resulted in a %coup
@ -3200,9 +3204,17 @@
/channel/subscription/[channel-id]/(scot %ud request-id) /channel/subscription/[channel-id]/(scot %ud request-id)
:: ::
++ subscription-wire ++ subscription-wire
|= [channel-id=@t request-id=@ud =ship app=term] |= [channel-id=@t request-id=@ud as=$@(@p identity) =ship app=term]
^- wire ^- wire
(weld (channel-wire channel-id request-id) /(scot %p ship)/[app]) =/ from=@p
?@ as as
?+(-.as who.as %ours our)
%+ weld (channel-wire channel-id request-id)
::NOTE including the originating identity is important for the band-aid
:: solution currently present in +on-gall-response, where we may
:: need to issue a %leave after we've forgotten the identity with
:: which the subscription was opened.
/(scot %p ship)/[app]/(scot %p from)
-- --
:: end the =~ :: end the =~
:: ::

View File

@ -724,7 +724,7 @@
;< ~ bind:m (wait ~h12) ;< ~ bind:m (wait ~h12)
=/ wire /channel/timeout/'0123456789abcdef' =/ wire /channel/timeout/'0123456789abcdef'
;< mos=(list move) bind:m (take wire ~[/http-blah] %behn %wake ~) ;< mos=(list move) bind:m (take wire ~[/http-blah] %behn %wake ~)
=/ wire /channel/subscription/'0123456789abcdef'/1/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/1/~nul/two/~nul
(expect-moves mos (ex-gall-deal wire ~nul %two %leave ~) ~) (expect-moves mos (ex-gall-deal wire ~nul %two %leave ~) ~)
:: ::
++ test-channel-results-before-open ++ test-channel-results-before-open
@ -739,7 +739,7 @@
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
:: subscription gets a success message :: subscription gets a success message
:: ::
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
;< mos=(list move) bind:m ;< mos=(list move) bind:m
(take wire ~[/http-blah] %gall %unto %watch-ack ~) (take wire ~[/http-blah] %gall %unto %watch-ack ~)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -827,7 +827,7 @@
;< ~ bind:m (wait ~m1) ;< ~ bind:m (wait ~m1)
:: subscription gets a success message :: subscription gets a success message
:: ::
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
;< mos=(list move) bind:m ;< mos=(list move) bind:m
(take wire ~[/http-blah] %gall %unto %watch-ack ~) (take wire ~[/http-blah] %gall %unto %watch-ack ~)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -842,7 +842,7 @@
"subscription": 1} "subscription": 1}
] ]
''' '''
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ mov-1 (ex-gall-deal wire ~nul %two %leave ~) =/ mov-1 (ex-gall-deal wire ~nul %two %leave ~)
=/ mov-2 ex-204 =/ mov-2 ex-204
=/ mov-3 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00) =/ mov-3 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00)
@ -862,7 +862,7 @@
;< ~ bind:m (wait ~m1) ;< ~ bind:m (wait ~m1)
:: subscription gets a success message :: subscription gets a success message
:: ::
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
;< mos=(list move) bind:m ;< mos=(list move) bind:m
(take wire ~[/http-blah] %gall %unto %watch-ack ~) (take wire ~[/http-blah] %gall %unto %watch-ack ~)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -879,7 +879,7 @@
"path": "/one/two/three"} "path": "/one/two/three"}
] ]
''' '''
=/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two/~nul
=/ mov-1 (ex-gall-deal wire ~nul %two %watch /one/two/three) =/ mov-1 (ex-gall-deal wire ~nul %two %watch /one/two/three)
=/ mov-2 ex-204 =/ mov-2 ex-204
=/ mov-3 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00) =/ mov-3 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00)
@ -887,13 +887,13 @@
:: subscription gets 2 results :: subscription gets 2 results
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -934,7 +934,7 @@
"subscription": 1} "subscription": 1}
] ]
''' '''
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ mov-1 (ex-gall-deal wire ~nul %two %leave ~) =/ mov-1 (ex-gall-deal wire ~nul %two %leave ~)
=/ mov-2 ex-204 =/ mov-2 ex-204
;< ~ bind:m (expect-moves mos mov-1 mov-2 ~) ;< ~ bind:m (expect-moves mos mov-1 mov-2 ~)
@ -944,7 +944,7 @@
:: unsubscribe to the other. :: unsubscribe to the other.
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'2'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] [%n '2'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
=/ mov-1 =/ mov-1
@ -993,7 +993,7 @@
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
:: subscription gets a success message :: subscription gets a success message
:: ::
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
;< mos=(list move) bind:m ;< mos=(list move) bind:m
(take wire ~[/http-blah] %gall %unto %watch-ack ~) (take wire ~[/http-blah] %gall %unto %watch-ack ~)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -1024,7 +1024,7 @@
:: first subscription result gets sent to the user :: first subscription result gets sent to the user
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
=/ mov-1 =/ mov-1
@ -1060,7 +1060,7 @@
:: another subscription result while the user is disconnected :: another subscription result while the user is disconnected
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '2'] ~])] =/ =cage [%json !>(`json`[%a [%n '2'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -1097,7 +1097,7 @@
;< ~ bind:m (wait (add ~s1 clog-timeout:eyre-gate)) ;< ~ bind:m (wait (add ~s1 clog-timeout:eyre-gate))
:: subscription gets a success message :: subscription gets a success message
:: ::
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
;< mos=(list move) bind:m ;< mos=(list move) bind:m
(take wire ~[/http-blah] %gall %unto %watch-ack ~) (take wire ~[/http-blah] %gall %unto %watch-ack ~)
;< ~ bind:m (expect-moves mos ~) ;< ~ bind:m (expect-moves mos ~)
@ -1113,14 +1113,14 @@
=* loop-fact $ =* loop-fact $
?. =(cur max) ?. =(cur max)
;< tested-elsewhere=(list move) bind:m ;< tested-elsewhere=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
loop-fact(cur +(cur)) loop-fact(cur +(cur))
:: the next subscription result should trigger a clog :: the next subscription result should trigger a clog
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
=/ mov-1 =/ mov-1
@ -1132,7 +1132,7 @@
""" """
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ mov-2 (ex-gall-deal wire ~nul %two %leave ~) =/ mov-2 (ex-gall-deal wire ~nul %two %leave ~)
=/ mov-3 =/ mov-3
%- ex-continue-response :_ %.n :- ~ %- ex-continue-response :_ %.n :- ~
@ -1148,7 +1148,7 @@
:: the same event in which a clog triggered, should be silently ignored :: the same event in which a clog triggered, should be silently ignored
:: ::
;< mos=(list move) bind:m ;< mos=(list move) bind:m
=/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two =/ wire /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
=/ =cage [%json !>(`json`[%a [%n '1'] ~])] =/ =cage [%json !>(`json`[%a [%n '1'] ~])]
(take wire ~[/http-blah] %gall %unto %fact cage) (take wire ~[/http-blah] %gall %unto %fact cage)
(expect-moves mos ~) (expect-moves mos ~)
@ -1543,7 +1543,7 @@
%^ ex-gall-deal /channel/poke/'0123456789abcdef'/'0' ~nul %^ ex-gall-deal /channel/poke/'0123456789abcdef'/'0' ~nul
[%one %poke-as %a %json !>([%n '5'])] [%one %poke-as %a %json !>([%n '5'])]
=/ mov-2 =/ mov-2
%^ ex-gall-deal /channel/subscription/'0123456789abcdef'/'1'/~nul/two %^ ex-gall-deal /channel/subscription/'0123456789abcdef'/'1'/~nul/two/~nul
~nul ~nul
[%two %watch /one/two/three] [%two %watch /one/two/three]
=/ mov-3 (ex-response 204 ['set-cookie' cookie-string]~ ~) =/ mov-3 (ex-response 204 ['set-cookie' cookie-string]~ ~)