@@ -57,26 +57,30 @@ impl ListenerInfo {
5757}
5858
5959pub struct ListenersManager {
60- configuration_channel : mpsc:: Receiver < ListenerConfigurationChange > ,
60+ listener_configuration_channel : mpsc:: Receiver < ListenerConfigurationChange > ,
6161 route_configuration_channel : mpsc:: Receiver < RouteConfigurationChange > ,
6262 listener_handles : BTreeMap < & ' static str , ListenerInfo > ,
6363}
6464
6565impl ListenersManager {
6666 pub fn new (
67- configuration_channel : mpsc:: Receiver < ListenerConfigurationChange > ,
67+ listener_configuration_channel : mpsc:: Receiver < ListenerConfigurationChange > ,
6868 route_configuration_channel : mpsc:: Receiver < RouteConfigurationChange > ,
6969 ) -> Self {
70- ListenersManager { configuration_channel, route_configuration_channel, listener_handles : BTreeMap :: new ( ) }
70+ ListenersManager {
71+ listener_configuration_channel,
72+ route_configuration_channel,
73+ listener_handles : BTreeMap :: new ( ) ,
74+ }
7175 }
7276
73- pub async fn start ( mut self ) -> Result < ( ) > {
77+ pub async fn start ( mut self , ct : tokio_util :: sync :: CancellationToken ) -> Result < ( ) > {
7478 let ( tx_secret_updates, _) = broadcast:: channel ( 16 ) ;
7579 let ( tx_route_updates, _) = broadcast:: channel ( 16 ) ;
76-
80+ // TODO: create child token for each listener?
7781 loop {
7882 tokio:: select! {
79- Some ( listener_configuration_change) = self . configuration_channel . recv( ) => {
83+ Some ( listener_configuration_change) = self . listener_configuration_channel . recv( ) => {
8084 match listener_configuration_change {
8185 ListenerConfigurationChange :: Added ( boxed) => {
8286 let ( factory, listener_conf) = * boxed;
@@ -112,9 +116,9 @@ impl ListenersManager {
112116 warn!( "Internal problem when updating a route: {e}" ) ;
113117 }
114118 } ,
115- else => {
116- warn!( "All listener manager channels are closed... exiting" ) ;
117- return Err ( "All listener manager channels are closed...exiting" . into ( ) ) ;
119+ _ = ct . cancelled ( ) => {
120+ warn!( "Listener manager exiting" ) ;
121+ return Ok ( ( ) ) ;
118122 }
119123 }
120124 }
0 commit comments