Commit fec9716 1 parent b001ffd commit fec9716 Copy full SHA for fec9716
File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 20
20
use std:: io:: Cursor ;
21
21
use std:: net:: SocketAddr ;
22
22
use std:: sync:: Arc ;
23
+ use std:: time:: Duration ;
23
24
24
25
use aquatic_udp_protocol:: Response ;
25
26
use derive_more:: Constructor ;
@@ -240,9 +241,16 @@ impl Udp {
240
241
debug ! ( target: "UDP Tracker" , "From: {}" , & remote_addr) ;
241
242
debug ! ( target: "UDP Tracker" , "Payload: {:?}" , payload) ;
242
243
243
- let response = handle_packet ( remote_addr, payload, & tracker) . await ;
244
+ let response_fut = handle_packet ( remote_addr, payload, & tracker) ;
244
245
245
- Udp :: send_response ( socket_clone, remote_addr, response) . await ;
246
+ match tokio:: time:: timeout ( Duration :: from_secs ( 5 ) , response_fut) . await {
247
+ Ok ( response) => {
248
+ Udp :: send_response ( socket_clone, remote_addr, response) . await ;
249
+ }
250
+ Err ( _) => {
251
+ error ! ( "Timeout occurred while processing the UDP request." ) ;
252
+ }
253
+ }
246
254
}
247
255
Err ( err) => {
248
256
error ! ( "Error reading UDP datagram from socket. Error: {:?}" , err) ;
You can’t perform that action at this time.
0 commit comments