Repository : http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
commit 6865fefce31cdf702abb46f07851015c485f9b8b Author: Daniel Kopecek dkopecek@redhat.com Date: Tue Oct 14 17:13:08 2014 +0200
Generate transaction id from the time in seconds and transaction number
src/Daemon/Firewall/Backend.cpp | 9 ++++++++- src/Daemon/Firewall/Backend.hpp | 2 ++ 2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/src/Daemon/Firewall/Backend.cpp b/src/Daemon/Firewall/Backend.cpp index 43dc1ae..cab311e 100644 --- a/src/Daemon/Firewall/Backend.cpp +++ b/src/Daemon/Firewall/Backend.cpp @@ -17,17 +17,24 @@ // Authors: Daniel Kopecek dkopecek@redhat.com // #include "Common/Types.hpp" +#include "Common/Utility.hpp" #include "Daemon/Firewall/Transaction.hpp" #include "Backend.hpp" #include <mutex> +#include <time.h>
namespace firewalld { + Backend::Backend() + { + _transaction_counter = 0; + }
Pointer<Transaction> Backend::createTransaction() { std::lock_guardstd::mutex backend_lock(_backend_mutex); - Pointer<Transaction> transaction = makePointer<Transaction>(""); + String identifier = numberToString(::time(nullptr)) + "-" + numberToString(_transaction_counter++); + Pointer<Transaction> transaction = makePointer<Transaction>(identifier); _transactions.push_back(transaction); return transaction; } diff --git a/src/Daemon/Firewall/Backend.hpp b/src/Daemon/Firewall/Backend.hpp index 97eb0ca..109520a 100644 --- a/src/Daemon/Firewall/Backend.hpp +++ b/src/Daemon/Firewall/Backend.hpp @@ -30,6 +30,7 @@ namespace firewalld class Backend { public: + Backend(); virtual const UString& identifier() const = 0; Pointer<Transaction> createTransaction(); void commitTransaction(Pointer<Transaction> transaction); @@ -43,6 +44,7 @@ namespace firewalld private: PointerVector<Transaction> _transactions; mutable std::mutex _backend_mutex; + uint64_t _transaction_counter; };
} /* namespace firewalld */
firewalld-recode@lists.fedorahosted.org