Skip to content

Commit

Permalink
dnfdaemon: resolve and do_transaction cannot run simultaneously
Browse files Browse the repository at this point in the history
Since resolve() method re-sets transaction, use transaction mutex to
prevent running Goal.resolve() if another transaction is running.
  • Loading branch information
m-blaha authored and jan-kolarik committed Nov 12, 2024
1 parent 7bc0a1c commit 4ebad76
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dnf5daemon-server/services/goal/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ void Goal::dbus_register() {
}

sdbus::MethodReply Goal::resolve(sdbus::MethodCall & call) {
auto & transaction_mutex = session.get_transaction_mutex();
if (!transaction_mutex.try_lock()) {
//TODO(mblaha): use specialized exception class
throw std::runtime_error("Cannot acquire transaction lock (another transaction is running).");
}
std::lock_guard<std::mutex> transaction_lock(transaction_mutex, std::adopt_lock);

// read options from dbus call
dnfdaemon::KeyValueMap options;
call >> options;
Expand Down

0 comments on commit 4ebad76

Please sign in to comment.