@@ -169,6 +169,8 @@ where
169
169
{
170
170
if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
171
171
let delay = if let Ok ( nic) = guard. as_nic_mut ( ) {
172
+ nic. set_polling_mode ( false ) ;
173
+
172
174
nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
173
175
. map ( |d| d. total_micros ( ) )
174
176
} else {
@@ -178,10 +180,6 @@ where
178
180
delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
179
181
) ;
180
182
}
181
-
182
- if let Ok ( device) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
183
- device. set_polling_mode ( false ) ;
184
- }
185
183
}
186
184
187
185
return t;
@@ -195,6 +193,8 @@ where
195
193
{
196
194
if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
197
195
let delay = if let Ok ( nic) = guard. as_nic_mut ( ) {
196
+ nic. set_polling_mode ( false ) ;
197
+
198
198
nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
199
199
. map ( |d| d. total_micros ( ) )
200
200
} else {
@@ -204,10 +204,6 @@ where
204
204
delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
205
205
) ;
206
206
}
207
-
208
- if let Ok ( device) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
209
- device. set_polling_mode ( false ) ;
210
- }
211
207
}
212
208
213
209
return Err ( Errno :: Time ) ;
@@ -217,6 +213,8 @@ where
217
213
if backoff. is_completed ( ) {
218
214
let delay = if let Some ( mut guard) = crate :: executor:: network:: NIC . try_lock ( ) {
219
215
if let Ok ( nic) = guard. as_nic_mut ( ) {
216
+ nic. set_polling_mode ( false ) ;
217
+
220
218
nic. poll_delay ( Instant :: from_micros_const ( now. try_into ( ) . unwrap ( ) ) )
221
219
. map ( |d| d. total_micros ( ) )
222
220
} else {
@@ -233,17 +231,12 @@ where
233
231
let wakeup_time =
234
232
timeout. map ( |duration| start + u64:: try_from ( duration. as_micros ( ) ) . unwrap ( ) ) ;
235
233
236
- // allow network interrupts
237
- if let Ok ( device) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
238
- device. set_polling_mode ( false ) ;
239
- }
240
-
241
234
// switch to another task
242
235
task_notify. wait ( wakeup_time) ;
243
236
244
237
// restore default values
245
- if let Ok ( device ) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
246
- device . set_polling_mode ( true ) ;
238
+ if let Ok ( nic ) = crate :: executor:: network:: NIC . lock ( ) . as_nic_mut ( ) {
239
+ nic . set_polling_mode ( true ) ;
247
240
}
248
241
249
242
backoff. reset ( ) ;
0 commit comments