@@ -155,101 +155,27 @@ where
155155
156156 let now = crate :: arch:: kernel:: systemtime:: now_micros ( ) ;
157157 if let Poll :: Ready ( t) = result {
158- // allow network interrupts
159- #[ cfg( feature = "net" ) ]
160- {
161- if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
162- let delay = if let Ok ( nic) = guard. as_nic_mut ( ) {
163- nic. set_polling_mode ( false ) ;
164-
165- nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
166- . map ( |d| d. total_micros ( ) )
167- } else {
168- None
169- } ;
170- core_local:: core_scheduler ( ) . add_network_timer (
171- delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
172- ) ;
173- }
174- }
175-
176158 return t;
177159 }
178160
179161 if let Some ( duration) = timeout
180162 && Duration :: from_micros ( now - start) >= duration
181163 {
182- // allow network interrupts
183- #[ cfg( feature = "net" ) ]
184- {
185- if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
186- let delay = if let Ok ( nic) = guard. as_nic_mut ( ) {
187- nic. set_polling_mode ( false ) ;
188-
189- nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
190- . map ( |d| d. total_micros ( ) )
191- } else {
192- None
193- } ;
194- core_local:: core_scheduler ( ) . add_network_timer (
195- delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
196- ) ;
197- }
198- }
199-
200164 return Err ( Errno :: Time ) ;
201165 }
202166
203- # [ cfg ( feature = "net" ) ]
167+ // TODO: I have no idea whether this is correct
204168 if backoff. is_completed ( ) {
205- let delay = if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
206- if let Ok ( nic) = guard. as_nic_mut ( ) {
207- nic. set_polling_mode ( false ) ;
208-
209- nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
210- . map ( |d| d. total_micros ( ) )
211- } else {
212- None
213- }
214- } else {
215- None
216- } ;
217-
218- if delay. unwrap_or ( 10_000_000 ) > 10_000 {
219- core_local:: core_scheduler ( ) . add_network_timer (
220- delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
221- ) ;
222- let wakeup_time =
223- timeout. map ( |duration| start + u64:: try_from ( duration. as_micros ( ) ) . unwrap ( ) ) ;
224-
225- // switch to another task
226- task_notify. wait ( wakeup_time) ;
227-
228- // restore default values
229- if let Ok ( nic) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
230- nic. set_polling_mode ( true ) ;
231- }
232-
233- backoff. reset ( ) ;
234- }
235- } else {
236- backoff. snooze ( ) ;
237- }
238-
239- #[ cfg( not( feature = "net" ) ) ]
240- {
241- if backoff. is_completed ( ) {
242- let wakeup_time =
243- timeout. map ( |duration| start + u64:: try_from ( duration. as_micros ( ) ) . unwrap ( ) ) ;
169+ let wakeup_time =
170+ timeout. map ( |duration| start + u64:: try_from ( duration. as_micros ( ) ) . unwrap ( ) ) ;
244171
245- // switch to another task
246- task_notify. wait ( wakeup_time) ;
172+ // switch to another task
173+ task_notify. wait ( wakeup_time) ;
247174
248- // restore default values
249- backoff. reset ( ) ;
250- } else {
251- backoff. snooze ( ) ;
252- }
175+ // restore default values
176+ backoff. reset ( ) ;
177+ } else {
178+ backoff. snooze ( ) ;
253179 }
254180 }
255181}
0 commit comments