summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/txtest.cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2008-11-26 16:27:32 +0000
committerKim van der Riet <kpvdr@apache.org>2008-11-26 16:27:32 +0000
commitbdfbb79c925b2ae50857d5fda6a9b017bcf8d22b (patch)
treec0487f192495d12ff1bc54d75f51f065916b6840 /qpid/cpp/src/tests/txtest.cpp
parent07c5f4f82705b4d9ab23f77c5a16b721d40618d4 (diff)
downloadqpid-python-bdfbb79c925b2ae50857d5fda6a9b017bcf8d22b.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@720910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/txtest.cpp')
-rw-r--r--qpid/cpp/src/tests/txtest.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/qpid/cpp/src/tests/txtest.cpp b/qpid/cpp/src/tests/txtest.cpp
index a569bdd648..0c8ce90648 100644
--- a/qpid/cpp/src/tests/txtest.cpp
+++ b/qpid/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);
}
};