Commit 0eb1a810 authored by unknown's avatar unknown

ndb - use reentrant functions in HugoCalulator


ndb/test/src/HugoCalculator.cpp:
  Use reentrant function in HugoCalulator
parent 41c1a6c6
...@@ -72,13 +72,14 @@ HugoCalculator::Int64 calcValue(int record, int attrib, int updates) const; ...@@ -72,13 +72,14 @@ HugoCalculator::Int64 calcValue(int record, int attrib, int updates) const;
HugoCalculator::float calcValue(int record, int attrib, int updates) const; HugoCalculator::float calcValue(int record, int attrib, int updates) const;
HugoCalculator::double calcValue(int record, int attrib, int updates) const; HugoCalculator::double calcValue(int record, int attrib, int updates) const;
#endif #endif
const char* const char*
HugoCalculator::calcValue(int record, HugoCalculator::calcValue(int record,
int attrib, int attrib,
int updates, int updates,
char* buf, char* buf,
int len) const { int len) const {
unsigned seed;
const NdbDictionary::Column* attr = m_tab.getColumn(attrib); const NdbDictionary::Column* attr = m_tab.getColumn(attrib);
Uint32 val; Uint32 val;
do do
...@@ -98,16 +99,15 @@ HugoCalculator::calcValue(int record, ...@@ -98,16 +99,15 @@ HugoCalculator::calcValue(int record,
if (attr->getPrimaryKey()) if (attr->getPrimaryKey())
{ {
srand(record + attrib); seed = record + attrib;
val = (record + attrib);
} }
else else
{ {
srand(record + attrib + updates); seed = record + attrib + updates;
val = rand();
} }
} while (0); } while (0);
val = rand_r(&seed);
if(attr->getNullable() && (((val >> 16) & 255) > 220)) if(attr->getNullable() && (((val >> 16) & 255) > 220))
return NULL; return NULL;
...@@ -115,14 +115,14 @@ HugoCalculator::calcValue(int record, ...@@ -115,14 +115,14 @@ HugoCalculator::calcValue(int record,
int pos= 4; int pos= 4;
while(pos + 4 < len) while(pos + 4 < len)
{ {
val= rand(); val= rand_r(&seed);
memcpy(buf+pos, &val, 4); memcpy(buf+pos, &val, 4);
pos++; pos++;
} }
if(pos < len) if(pos < len)
{ {
val= rand(); val= rand_r(&seed);
memcpy(buf+pos, &val, (len - pos)); memcpy(buf+pos, &val, (len - pos));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment