Emergency fix. boost::format doesn't have the thread safety we thought.

This commit is contained in:
JoelKatz
2013-04-08 17:16:18 -07:00
parent 66db6eac6a
commit 46dbd3e967
7 changed files with 12 additions and 11 deletions

View File

@@ -1154,19 +1154,19 @@ std::string STAmount::getFullText() const
static boost::format normal("%s/%s/%s"); static boost::format normal("%s/%s/%s");
if (mIsNative) if (mIsNative)
{ {
return str(nativeFormat % getText()); return str(boost::format(nativeFormat) % getText());
} }
else if (!mIssuer) else if (!mIssuer)
{ {
return str(noIssuer % getText() % getHumanCurrency()); return str(boost::format(noIssuer) % getText() % getHumanCurrency());
} }
else if (mIssuer == ACCOUNT_ONE) else if (mIssuer == ACCOUNT_ONE)
{ {
return str(issuerOne % getText() % getHumanCurrency()); return str(boost::format(issuerOne) % getText() % getHumanCurrency());
} }
else else
{ {
return str(normal return str(boost::format(normal)
% getText() % getText()
% getHumanCurrency() % getHumanCurrency()
% RippleAddress::createHumanAccountID(mIssuer)); % RippleAddress::createHumanAccountID(mIssuer));

View File

@@ -154,7 +154,8 @@ void HashedObjectStore::bulkWrite()
case hotTRANSACTION_NODE: type = 'N'; break; case hotTRANSACTION_NODE: type = 'N'; break;
default: type = 'U'; default: type = 'U';
} }
db->executeSQL(boost::str(fAdd % it->getHash().GetHex() % type % it->getIndex() % sqlEscape(it->getData()))); db->executeSQL(boost::str(boost::format(fAdd)
% it->getHash().GetHex() % type % it->getIndex() % sqlEscape(it->getData())));
} }
db->executeSQL("END TRANSACTION;"); db->executeSQL("END TRANSACTION;");

View File

@@ -127,7 +127,7 @@ ProofOfWork ProofOfWorkGenerator::getProof()
boost::mutex::scoped_lock sl(mLock); boost::mutex::scoped_lock sl(mLock);
std::string s = boost::str(f % challenge.GetHex() % mTarget.GetHex() % mIterations % now); std::string s = boost::str(boost::format(f) % challenge.GetHex() % mTarget.GetHex() % mIterations % now);
std::string c = mSecret.GetHex() + s; std::string c = mSecret.GetHex() + s;
s += "-" + Serializer::getSHA512Half(c).GetHex(); s += "-" + Serializer::getSHA512Half(c).GetHex();

View File

@@ -25,7 +25,7 @@ std::string SHAMapNode::getString() const
if ((mDepth == 0) && (mNodeID.isZero())) if ((mDepth == 0) && (mNodeID.isZero()))
return "NodeID(root)"; return "NodeID(root)";
return str(NodeID return str(boost::format(NodeID)
% boost::lexical_cast<std::string>(mDepth) % boost::lexical_cast<std::string>(mDepth)
% mNodeID.GetHex()); % mNodeID.GetHex());
} }

View File

@@ -260,7 +260,7 @@ std::string SerializedTransaction::getSQL(Serializer rawTxn, uint32 inLedger, ch
static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s)"); static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s)");
std::string rTxn = sqlEscape(rawTxn.peekData()); std::string rTxn = sqlEscape(rawTxn.peekData());
return str(bfTrans return str(boost::format(bfTrans)
% getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID() % getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID()
% getSequence() % inLedger % status % rTxn); % getSequence() % inLedger % status % rTxn);
} }
@@ -271,7 +271,7 @@ std::string SerializedTransaction::getMetaSQL(Serializer rawTxn, uint32 inLedger
static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)"); static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)");
std::string rTxn = sqlEscape(rawTxn.peekData()); std::string rTxn = sqlEscape(rawTxn.peekData());
return str(bfTrans return str(boost::format(bfTrans)
% getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID() % getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID()
% getSequence() % inLedger % status % rTxn % escapedMetaData); % getSequence() % inLedger % status % rTxn % escapedMetaData);
} }

View File

@@ -304,7 +304,7 @@ void ValidationCollection::condWrite()
void ValidationCollection::doWrite(Job&) void ValidationCollection::doWrite(Job&)
{ {
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "ValidationWrite")); LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "ValidationWrite"));
static boost::format insVal("INSERT INTO Validations " boost::format insVal("INSERT INTO Validations "
"(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);"); "(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);");
boost::mutex::scoped_lock sl(mValidationLock); boost::mutex::scoped_lock sl(mValidationLock);

View File

@@ -162,7 +162,7 @@ inline std::string strHex(const uint64 uiHost)
inline static std::string sqlEscape(const std::string& strSrc) inline static std::string sqlEscape(const std::string& strSrc)
{ {
static boost::format f("X'%s'"); static boost::format f("X'%s'");
return str(f % strHex(strSrc)); return str(boost::format(f) % strHex(strSrc));
} }
inline static std::string sqlEscape(const std::vector<unsigned char>& vecSrc) inline static std::string sqlEscape(const std::vector<unsigned char>& vecSrc)