Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrause committed Dec 16, 2024
1 parent a1d4ec6 commit 083a79f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ To install or update LODA, please follow the [installation instructions](https:/

## [Unreleased]

## v24.12.16

### Bugfixes

* Fix error handling

## v24.12.15

### Enhancements
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/boinc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ void Boinc::run() {
!Git::git(progs_dir, "pull origin main -q --ff-only", false)) {
Log::get().error("Failed to update programs repository", false);
const auto age = getFileAgeInDays(progs_dir);
if (age >= 7) {
Log::get().warn("Deleting corrupt programs directory (age: " +
std::to_string(age) + " days)");
Log::get().info("Programs directory age: " + std::to_string(age) +
" days");
if (age >= 3) { // magic number
Log::get().warn("Deleting corrupt programs directory");
rmDirRecursive(progs_dir);
}
}
Expand Down
14 changes: 10 additions & 4 deletions src/mine/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Miner::reload() {
manager->releaseStats(); // not needed anymore
}

void shutdown() {
void signalShutdown() {
if (!Signals::HALT) {
Log::get().info("Signaling shutdown");
Signals::HALT = true;
Expand All @@ -79,9 +79,10 @@ void Miner::mine() {
std::this_thread::sleep_for(delay);
}
monitor->writeProgress(); // final write
shutdown();
signalShutdown();
});

bool error = false;
try {
// load manager
if (!manager) {
Expand All @@ -95,16 +96,21 @@ void Miner::mine() {
Log::get().error(
"Error during initialization or mining: " + std::string(e.what()),
false);
shutdown();
signalShutdown();
error = true;
} catch (...) {
Log::get().error("Unknown error during initialization or mining", false);
shutdown();
signalShutdown();
error = true;
}
try {
monitor_thread.join();
} catch (...) {
Log::get().warn("Error joining progress monitoring thread");
}
if (error) {
Log::get().error("Exiting due to error", true); // exit with error
}
} else {
// load manager
if (!manager) {
Expand Down

0 comments on commit 083a79f

Please sign in to comment.