File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ pub struct AppConfig {
142
142
pub ev_battery_logger : Option < PathBuf > ,
143
143
pub ev_battery_capacity : u64 ,
144
144
pub ev_factor : f32 ,
145
+
146
+ #[ serde( skip) ]
147
+ pub restart_requested : bool ,
145
148
}
146
149
147
150
impl Default for AppConfig {
@@ -176,6 +179,7 @@ impl Default for AppConfig {
176
179
ev_battery_logger : None ,
177
180
ev_battery_capacity : 22000 ,
178
181
ev_factor : 0.075 ,
182
+ restart_requested : false ,
179
183
}
180
184
}
181
185
}
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ async fn transfer_monitor(
87
87
usb_bytes_written : Arc < AtomicUsize > ,
88
88
tcp_bytes_written : Arc < AtomicUsize > ,
89
89
read_timeout : Duration ,
90
+ config : SharedConfig ,
90
91
) -> Result < ( ) > {
91
92
let mut usb_bytes_out_last: usize = 0 ;
92
93
let mut tcp_bytes_out_last: usize = 0 ;
@@ -153,6 +154,12 @@ async fn transfer_monitor(
153
154
stall_tcp_bytes_last = tcp_bytes_out;
154
155
}
155
156
157
+ // check if we need to restart
158
+ if config. read ( ) . await . restart_requested {
159
+ config. write ( ) . await . restart_requested = false ;
160
+ return Err ( "config reload request => restarting connection" . into ( ) ) ;
161
+ }
162
+
156
163
sleep ( Duration :: from_millis ( 100 ) ) . await ;
157
164
}
158
165
}
@@ -384,6 +391,7 @@ pub async fn io_loop(
384
391
file_bytes,
385
392
stream_bytes,
386
393
read_timeout,
394
+ config. clone ( ) ,
387
395
) ) ;
388
396
389
397
// Stop as soon as one of them errors
You can’t perform that action at this time.
0 commit comments