diff options
author | Kim van der Riet <kpvdr@apache.org> | 2008-11-26 16:27:32 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2008-11-26 16:27:32 +0000 |
commit | a39a105d5c2c7af862be913d5e61c727a1de6ad9 (patch) | |
tree | ad78a20595621d6038f488f0fba58cf82c65d870 /cpp/src/tests/txtest.cpp | |
parent | b56d710804bfa3d94e378efeae10e66885d818a7 (diff) | |
download | qpid-python-a39a105d5c2c7af862be913d5e61c727a1de6ad9.tar.gz |
Fixed problem of recurring xids (0, 1, 2...) on successive txtest runs which can cause journal txn recover failures. The xid is now the 36-char string representation of a UUID and should have a great test-to-test diversity.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@720910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/txtest.cpp')
-rw-r--r-- | cpp/src/tests/txtest.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cpp/src/tests/txtest.cpp b/cpp/src/tests/txtest.cpp index a569bdd648..0c8ce90648 100644 --- a/cpp/src/tests/txtest.cpp +++ b/cpp/src/tests/txtest.cpp @@ -33,6 +33,7 @@ #include "qpid/client/SubscriptionManager.h" #include "qpid/framing/Array.h" #include "qpid/framing/Buffer.h" +#include "qpid/sys/uuid.h" using namespace qpid; using namespace qpid::client; @@ -128,10 +129,11 @@ struct Transfer : public Client, public Runnable std::string src; std::string dest; Thread thread; - unsigned long xid_cnt; + uuid_t uuid; + char uuidStr[37]; // Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + trailing \0 framing::Xid xid; - Transfer(const std::string& to, const std::string& from) : src(to), dest(from), xid_cnt(0), xid(0x4c414e47, "", from) {} + Transfer(const std::string& to, const std::string& from) : src(to), dest(from), xid(0x4c414e47, "", from) {} void run() { @@ -150,7 +152,7 @@ struct Transfer : public Client, public Runnable Message in; Message out("", dest); if (opts.dtx) { - setNextXid(xid); + setNewXid(xid); session.dtxStart(arg::xid=xid); } for (uint m = 0; m < opts.msgsPerTx; m++) { @@ -174,10 +176,10 @@ struct Transfer : public Client, public Runnable } } - void setNextXid(framing::Xid& xid) { - std::ostringstream oss; - oss << std::setfill('0') << std::hex << "xid-" << std::setw(12) << (++xid_cnt); - xid.setGlobalId(oss.str()); + void setNewXid(framing::Xid& xid) { + ::uuid_generate(uuid); + ::uuid_unparse(uuid, uuidStr); + xid.setGlobalId(uuidStr); } }; |