Skip to content

Commit 083a79f

Browse files
committed
fix error handling
1 parent a1d4ec6 commit 083a79f

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
## v24.12.16
6+
7+
### Bugfixes
8+
9+
* Fix error handling
10+
511
## v24.12.15
612

713
### Enhancements

src/cmd/boinc.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ void Boinc::run() {
131131
!Git::git(progs_dir, "pull origin main -q --ff-only", false)) {
132132
Log::get().error("Failed to update programs repository", false);
133133
const auto age = getFileAgeInDays(progs_dir);
134-
if (age >= 7) {
135-
Log::get().warn("Deleting corrupt programs directory (age: " +
136-
std::to_string(age) + " days)");
134+
Log::get().info("Programs directory age: " + std::to_string(age) +
135+
" days");
136+
if (age >= 3) { // magic number
137+
Log::get().warn("Deleting corrupt programs directory");
137138
rmDirRecursive(progs_dir);
138139
}
139140
}

src/mine/miner.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void Miner::reload() {
6161
manager->releaseStats(); // not needed anymore
6262
}
6363

64-
void shutdown() {
64+
void signalShutdown() {
6565
if (!Signals::HALT) {
6666
Log::get().info("Signaling shutdown");
6767
Signals::HALT = true;
@@ -79,9 +79,10 @@ void Miner::mine() {
7979
std::this_thread::sleep_for(delay);
8080
}
8181
monitor->writeProgress(); // final write
82-
shutdown();
82+
signalShutdown();
8383
});
8484

85+
bool error = false;
8586
try {
8687
// load manager
8788
if (!manager) {
@@ -95,16 +96,21 @@ void Miner::mine() {
9596
Log::get().error(
9697
"Error during initialization or mining: " + std::string(e.what()),
9798
false);
98-
shutdown();
99+
signalShutdown();
100+
error = true;
99101
} catch (...) {
100102
Log::get().error("Unknown error during initialization or mining", false);
101-
shutdown();
103+
signalShutdown();
104+
error = true;
102105
}
103106
try {
104107
monitor_thread.join();
105108
} catch (...) {
106109
Log::get().warn("Error joining progress monitoring thread");
107110
}
111+
if (error) {
112+
Log::get().error("Exiting due to error", true); // exit with error
113+
}
108114
} else {
109115
// load manager
110116
if (!manager) {

0 commit comments

Comments
 (0)