@@ -94,7 +94,7 @@ impl VmbusClient {
94
94
/// Creates a new instance with a receiver for incoming synic messages.
95
95
pub fn new (
96
96
synic : Arc < dyn SynicClient > ,
97
- notify_send : mesh:: Sender < ClientNotification > ,
97
+ offer_send : mesh:: Sender < OfferInfo > ,
98
98
msg_source : impl VmbusMessageSource + ' static ,
99
99
spawner : & impl Spawn ,
100
100
) -> Self {
@@ -113,7 +113,7 @@ impl VmbusClient {
113
113
inner,
114
114
task_recv,
115
115
running : false ,
116
- notify_send ,
116
+ offer_send ,
117
117
msg_source,
118
118
client_request_recv,
119
119
state : ClientState :: Disconnected ,
@@ -287,12 +287,6 @@ pub struct OfferInfo {
287
287
pub response_recv : mesh:: Receiver < ChannelResponse > ,
288
288
}
289
289
290
- #[ derive( Debug ) ]
291
- pub enum ClientNotification {
292
- Offer ( OfferInfo ) ,
293
- Revoke ( ChannelId ) ,
294
- }
295
-
296
290
#[ derive( Debug ) ]
297
291
enum ClientRequest {
298
292
InitiateContact ( Rpc < InitiateContactRequest , Result < VersionInfo , ConnectError > > ) ,
@@ -495,7 +489,7 @@ struct ClientTask<T: VmbusMessageSource> {
495
489
running : bool ,
496
490
modify_request : Option < Rpc < ModifyConnectionRequest , ConnectionState > > ,
497
491
msg_source : T ,
498
- notify_send : mesh:: Sender < ClientNotification > ,
492
+ offer_send : mesh:: Sender < OfferInfo > ,
499
493
task_recv : mesh:: Receiver < TaskRequest > ,
500
494
client_request_recv : mesh:: Receiver < ClientRequest > ,
501
495
}
@@ -707,7 +701,7 @@ impl<T: VmbusMessageSource> ClientTask<T> {
707
701
if let ClientState :: RequestingOffers ( _, send) = & self . state {
708
702
send. send ( offer_info) ;
709
703
} else {
710
- self . notify_send . send ( ClientNotification :: Offer ( offer_info) ) ;
704
+ self . offer_send . send ( offer_info) ;
711
705
}
712
706
}
713
707
}
@@ -733,6 +727,8 @@ impl<T: VmbusMessageSource> ClientTask<T> {
733
727
. response_send
734
728
. send ( ChannelResponse :: TeardownGpadl ( gpadl_id) ) ;
735
729
} else {
730
+ // TODO: is this really necessary? The host should have
731
+ // already unmapped all GPADLs. Remove if possible.
736
732
send_message (
737
733
self . inner . synic . as_ref ( ) ,
738
734
& protocol:: GpadlTeardown {
@@ -748,16 +744,20 @@ impl<T: VmbusMessageSource> ClientTask<T> {
748
744
false
749
745
} ) ;
750
746
747
+ // Drop the channel, which will close the response channel, which will
748
+ // cause the client to know the channel has been revoked.
749
+ //
750
+ // TODO: this is wrong--client requests can still come in after this,
751
+ // and they will fail to find the channel by channel ID and panic (or
752
+ // worse, the channel ID will get reused). Either find and drop the
753
+ // associated incoming request channel here, or keep this channel object
754
+ // around until the client is done with it.
751
755
self . inner . channels . remove ( & rescind. channel_id ) ;
752
756
753
757
// Tell the host we're not referencing the client ID anymore.
754
758
self . inner . send ( & protocol:: RelIdReleased {
755
759
channel_id : rescind. channel_id ,
756
760
} ) ;
757
-
758
- // At this point the offer can be revoked from the relay.
759
- self . notify_send
760
- . send ( ClientNotification :: Revoke ( rescind. channel_id ) ) ;
761
761
}
762
762
763
763
fn handle_offers_delivered ( & mut self ) {
@@ -1549,23 +1549,19 @@ mod tests {
1549
1549
1550
1550
impl VmbusMessageSource for TestMessageSource { }
1551
1551
1552
- fn test_init ( ) -> (
1553
- Arc < TestServer > ,
1554
- VmbusClient ,
1555
- mesh:: Receiver < ClientNotification > ,
1556
- ) {
1552
+ fn test_init ( ) -> ( Arc < TestServer > , VmbusClient , mesh:: Receiver < OfferInfo > ) {
1557
1553
let pool = DefaultPool :: new ( ) ;
1558
1554
let driver = pool. driver ( ) ;
1559
1555
let ( msg_send, msg_recv) = mesh:: channel ( ) ;
1560
1556
let server = Arc :: new ( TestServer {
1561
1557
messages : Mutex :: new ( Vec :: new ( ) ) ,
1562
1558
send : msg_send,
1563
1559
} ) ;
1564
- let ( notify_send , notify_recv ) = mesh:: channel ( ) ;
1560
+ let ( offer_send , offer_recv ) = mesh:: channel ( ) ;
1565
1561
1566
1562
let mut client = VmbusClient :: new (
1567
1563
Arc :: new ( server. clone ( ) ) ,
1568
- notify_send ,
1564
+ offer_send ,
1569
1565
TestMessageSource { msg_recv } ,
1570
1566
& driver,
1571
1567
) ;
@@ -1574,7 +1570,7 @@ mod tests {
1574
1570
. spawn ( move || pool. run ( ) )
1575
1571
. unwrap ( ) ;
1576
1572
1577
- ( server, client, notify_recv )
1573
+ ( server, client, offer_recv )
1578
1574
}
1579
1575
1580
1576
#[ async_test]
@@ -1997,7 +1993,7 @@ mod tests {
1997
1993
1998
1994
#[ async_test]
1999
1995
async fn test_hot_add_remove ( ) {
2000
- let ( server, mut client, mut notify_recv ) = test_init ( ) ;
1996
+ let ( server, mut client, mut offer_recv ) = test_init ( ) ;
2001
1997
2002
1998
server. connect ( & mut client) . await ;
2003
1999
let offer = protocol:: OfferChannel {
@@ -2017,9 +2013,7 @@ mod tests {
2017
2013
} ;
2018
2014
2019
2015
server. send ( in_msg ( MessageType :: OFFER_CHANNEL , offer) ) ;
2020
- let ClientNotification :: Offer ( info) = notify_recv. next ( ) . await . unwrap ( ) else {
2021
- panic ! ( "invalid request" )
2022
- } ;
2016
+ let mut info = offer_recv. next ( ) . await . unwrap ( ) ;
2023
2017
2024
2018
assert_eq ! ( offer, info. offer) ;
2025
2019
@@ -2037,8 +2031,7 @@ mod tests {
2037
2031
} )
2038
2032
) ;
2039
2033
2040
- let request = notify_recv. next ( ) . await . unwrap ( ) ;
2041
- assert ! ( matches!( request, ClientNotification :: Revoke ( ChannelId ( 5 ) ) ) ) ;
2034
+ assert ! ( info. response_recv. next( ) . await . is_none( ) ) ;
2042
2035
}
2043
2036
2044
2037
#[ async_test]
@@ -2144,7 +2137,7 @@ mod tests {
2144
2137
2145
2138
#[ async_test]
2146
2139
async fn test_gpadl_with_revoke ( ) {
2147
- let ( server, mut client, mut notify_recv ) = test_init ( ) ;
2140
+ let ( server, mut client, _offer_recv ) = test_init ( ) ;
2148
2141
let mut channel = server. get_channel ( & mut client) . await ;
2149
2142
let channel_id = ChannelId ( 0 ) ;
2150
2143
let gpadl_id = GpadlId ( 1 ) ;
@@ -2208,11 +2201,7 @@ mod tests {
2208
2201
OutgoingMessage :: new( & protocol:: RelIdReleased { channel_id } )
2209
2202
) ;
2210
2203
2211
- let ClientNotification :: Revoke ( id) = notify_recv. next ( ) . await . unwrap ( ) else {
2212
- panic ! ( "invalid request" )
2213
- } ;
2214
-
2215
- assert_eq ! ( id, channel_id) ;
2204
+ assert ! ( channel. response_recv. next( ) . await . is_none( ) ) ;
2216
2205
}
2217
2206
2218
2207
#[ async_test]
@@ -2250,7 +2239,7 @@ mod tests {
2250
2239
2251
2240
#[ async_test]
2252
2241
async fn test_hvsock ( ) {
2253
- let ( server, mut client, _notify_recv ) = test_init ( ) ;
2242
+ let ( server, mut client, _offer_recv ) = test_init ( ) ;
2254
2243
server. connect ( & mut client) . await ;
2255
2244
let request = HvsockConnectRequest {
2256
2245
service_id : Guid :: new_random ( ) ,
0 commit comments