File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -463,4 +463,4 @@ namespace dvars
463
463
};
464
464
}
465
465
466
- REGISTER_COMPONENT (dvars::component)
466
+ REGISTER_COMPONENT (dvars::component)
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ namespace motd
36
36
cached_file_header header{};
37
37
std::string data;
38
38
};
39
+
40
+ std::atomic_bool killed;
39
41
40
42
std::filesystem::path get_cache_folder ()
41
43
{
@@ -147,6 +149,11 @@ namespace motd
147
149
148
150
std::optional<std::string> download_image (const std::string& url)
149
151
{
152
+ if (killed)
153
+ {
154
+ return {};
155
+ }
156
+
150
157
const auto cached = read_cached_file (url);
151
158
if (cached.has_value ())
152
159
{
@@ -368,12 +375,25 @@ namespace motd
368
375
});
369
376
}
370
377
378
+ std::thread init_thread;
379
+
371
380
class component final : public component_interface
372
381
{
373
382
public:
383
+ void post_start () override
384
+ {
385
+ init_thread = std::thread ([]
386
+ {
387
+ init ();
388
+ });
389
+ }
390
+
374
391
void post_unpack () override
375
392
{
376
- init ();
393
+ if (init_thread.joinable ())
394
+ {
395
+ init_thread.join ();
396
+ }
377
397
378
398
command::add (" reloadmotd" , []()
379
399
{
@@ -385,6 +405,15 @@ namespace motd
385
405
init (false );
386
406
});
387
407
}
408
+
409
+ void pre_destroy () override
410
+ {
411
+ killed = true ;
412
+ if (init_thread.joinable ())
413
+ {
414
+ init_thread.join ();
415
+ }
416
+ }
388
417
};
389
418
}
390
419
You can’t perform that action at this time.
0 commit comments