4646
4747 /// Channel used to transmit to the ConnectionHandle the unsolicited
4848 /// messages received from the socket (multicast messages for instance).
49- unsolicited_messages_tx : Option < UnboundedSender < ( NetlinkMessage < T > , SocketAddr ) > > ,
49+ unsolicited_messages_tx :
50+ Option < UnboundedSender < ( NetlinkMessage < T > , SocketAddr ) > > ,
5051
5152 socket_closed : bool ,
5253}
5960{
6061 pub ( crate ) fn new (
6162 requests_rx : UnboundedReceiver < Request < T > > ,
62- unsolicited_messages_tx : UnboundedSender < ( NetlinkMessage < T > , SocketAddr ) > ,
63+ unsolicited_messages_tx : UnboundedSender < (
64+ NetlinkMessage < T > ,
65+ SocketAddr ,
66+ ) > ,
6367 protocol : isize ,
6468 ) -> io:: Result < Self > {
6569 let socket = S :: new ( protocol) ?;
@@ -86,20 +90,25 @@ where
8690 let mut socket = Pin :: new ( socket) ;
8791
8892 while !protocol. outgoing_messages . is_empty ( ) {
89- trace ! ( "found outgoing message to send checking if socket is ready" ) ;
90- if let Poll :: Ready ( Err ( e) ) = Pin :: as_mut ( & mut socket) . poll_ready ( cx) {
93+ trace ! (
94+ "found outgoing message to send checking if socket is ready"
95+ ) ;
96+ if let Poll :: Ready ( Err ( e) ) = Pin :: as_mut ( & mut socket) . poll_ready ( cx)
97+ {
9198 // Sink errors are usually not recoverable. The socket
9299 // probably shut down.
93100 warn ! ( "netlink socket shut down: {:?}" , e) ;
94101 self . socket_closed = true ;
95102 return ;
96103 }
97104
98- let ( mut message, addr) = protocol. outgoing_messages . pop_front ( ) . unwrap ( ) ;
105+ let ( mut message, addr) =
106+ protocol. outgoing_messages . pop_front ( ) . unwrap ( ) ;
99107 message. finalize ( ) ;
100108
101109 trace ! ( "sending outgoing message" ) ;
102- if let Err ( e) = Pin :: as_mut ( & mut socket) . start_send ( ( message, addr) ) {
110+ if let Err ( e) = Pin :: as_mut ( & mut socket) . start_send ( ( message, addr) )
111+ {
103112 error ! ( "failed to send message: {:?}" , e) ;
104113 self . socket_closed = true ;
105114 return ;
@@ -147,7 +156,9 @@ where
147156 if let Some ( mut stream) = self . requests_rx . as_mut ( ) {
148157 loop {
149158 match Pin :: new ( & mut stream) . poll_next ( cx) {
150- Poll :: Ready ( Some ( request) ) => self . protocol . request ( request) ,
159+ Poll :: Ready ( Some ( request) ) => {
160+ self . protocol . request ( request)
161+ }
151162 Poll :: Ready ( None ) => break ,
152163 Poll :: Pending => return ,
153164 }
@@ -159,7 +170,9 @@ where
159170
160171 pub fn forward_unsolicited_messages ( & mut self ) {
161172 if self . unsolicited_messages_tx . is_none ( ) {
162- while let Some ( ( message, source) ) = self . protocol . incoming_requests . pop_front ( ) {
173+ while let Some ( ( message, source) ) =
174+ self . protocol . incoming_requests . pop_front ( )
175+ {
163176 warn ! (
164177 "ignoring unsolicited message {:?} from {:?}" ,
165178 message, source
@@ -177,7 +190,9 @@ where
177190 ..
178191 } = self ;
179192
180- while let Some ( ( message, source) ) = protocol. incoming_requests . pop_front ( ) {
193+ while let Some ( ( message, source) ) =
194+ protocol. incoming_requests . pop_front ( )
195+ {
181196 if unsolicited_messages_tx
182197 . as_mut ( )
183198 . unwrap ( )
@@ -250,7 +265,9 @@ where
250265 }
251266
252267 pub fn should_shut_down ( & self ) -> bool {
253- self . socket_closed || ( self . unsolicited_messages_tx . is_none ( ) && self . requests_rx . is_none ( ) )
268+ self . socket_closed
269+ || ( self . unsolicited_messages_tx . is_none ( )
270+ && self . requests_rx . is_none ( ) )
254271 }
255272}
256273
@@ -272,7 +289,9 @@ where
272289 debug ! ( "forwarding unsolicited messages to the connection handle" ) ;
273290 pinned. forward_unsolicited_messages ( ) ;
274291
275- debug ! ( "forwaring responses to previous requests to the connection handle" ) ;
292+ debug ! (
293+ "forwaring responses to previous requests to the connection handle"
294+ ) ;
276295 pinned. forward_responses ( ) ;
277296
278297 debug ! ( "handling requests" ) ;
0 commit comments