Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c6de1967
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c6de1967
编写于
3月 10, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-13765]<fix>: redefine rand api.
上级
35b82d79
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
92 addition
and
79 deletion
+92
-79
contrib/test/craft/raftMain.c
contrib/test/craft/raftMain.c
+1
-1
contrib/test/craft/simulate_vnode.c
contrib/test/craft/simulate_vnode.c
+2
-2
examples/c/schemaless.c
examples/c/schemaless.c
+1
-1
include/os/osRand.h
include/os/osRand.h
+9
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-1
source/dnode/vnode/test/tqMetaTest.cpp
source/dnode/vnode/test/tqMetaTest.cpp
+9
-9
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+5
-5
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+3
-3
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+4
-4
source/libs/executor/test/lhashTests.cpp
source/libs/executor/test/lhashTests.cpp
+1
-1
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+1
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+25
-25
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+1
-1
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+1
-1
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+2
-2
source/libs/sync/src/syncEnv.c
source/libs/sync/src/syncEnv.c
+1
-1
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+1
-1
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+1
-1
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+1
-1
source/libs/transport/src/rpcMain.c
source/libs/transport/src/rpcMain.c
+1
-1
source/libs/wal/test/walMetaTest.cpp
source/libs/wal/test/walMetaTest.cpp
+3
-3
source/os/src/osEnv.c
source/os/src/osEnv.c
+1
-1
source/os/src/osRand.c
source/os/src/osRand.c
+5
-1
source/util/src/tdes.c
source/util/src/tdes.c
+1
-1
source/util/src/tskiplist.c
source/util/src/tskiplist.c
+4
-4
source/util/test/codingTests.cpp
source/util/test/codingTests.cpp
+2
-2
source/util/test/pageBufferTest.cpp
source/util/test/pageBufferTest.cpp
+1
-1
source/util/test/skiplistTest.cpp
source/util/test/skiplistTest.cpp
+4
-4
未找到文件。
contrib/test/craft/raftMain.c
浏览文件 @
c6de1967
...
...
@@ -377,7 +377,7 @@ void printConf(SRaftServerConfig *pConf) {
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
int32_t
ret
;
exe_name
=
argv
[
0
];
...
...
contrib/test/craft/simulate_vnode.c
浏览文件 @
c6de1967
...
...
@@ -132,7 +132,7 @@ static void proposeValue(struct raft *r) {
buf
.
base
=
raft_malloc
(
buf
.
len
);
// mock ts value
int
vid
=
r
and
()
%
VNODE_COUNT
;
int
vid
=
taosR
and
()
%
VNODE_COUNT
;
snprintf
(
buf
.
base
,
buf
.
len
,
"%d:value_%ld"
,
vid
,
time
(
NULL
));
printf
(
"propose value: %s
\n
"
,
(
char
*
)
buf
.
base
);
...
...
@@ -174,7 +174,7 @@ void usage() {
}
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
exe_name
=
argv
[
0
];
if
(
argc
<
2
)
{
...
...
examples/c/schemaless.c
浏览文件 @
c6de1967
...
...
@@ -19,7 +19,7 @@ void shuffle(char**lines, size_t n)
size_t
i
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
size_t
j
=
i
+
r
and
()
/
(
RAND_MAX
/
(
n
-
i
)
+
1
);
size_t
j
=
i
+
taosR
and
()
/
(
RAND_MAX
/
(
n
-
i
)
+
1
);
char
*
t
=
lines
[
j
];
lines
[
j
]
=
lines
[
i
];
lines
[
i
]
=
t
;
...
...
include/os/osRand.h
浏览文件 @
c6de1967
...
...
@@ -20,7 +20,16 @@
extern
"C"
{
#endif
// If the error is in a third-party library, place this header file under the third-party library header file.
#ifndef ALLOW_FORBID_FUNC
#define rand RAND_FUNC_TAOS_FORBID
#define srand SRAND_FUNC_TAOS_FORBID
#define rand_r RANDR_FUNC_TAOS_FORBID
#endif
void
taosSeedRand
(
uint32_t
seed
);
uint32_t
taosRand
(
void
);
uint32_t
taosRandR
(
uint32_t
*
pSeed
);
void
taosRandStr
(
char
*
str
,
int32_t
size
);
uint32_t
taosSafeRand
(
void
);
...
...
source/client/src/clientEnv.c
浏览文件 @
c6de1967
...
...
@@ -208,7 +208,7 @@ void taos_init_imp(void) {
atexit
(
taos_cleanup
);
errno
=
TSDB_CODE_SUCCESS
;
sr
and
(
taosGetTimestampSec
());
taosSeedR
and
(
taosGetTimestampSec
());
deltaToUtcInitOnce
();
...
...
source/dnode/vnode/test/tqMetaTest.cpp
浏览文件 @
c6de1967
...
...
@@ -168,10 +168,10 @@ TEST_F(TqMetaUpdateAppendTest, intxnPersist) {
}
TEST_F
(
TqMetaUpdateAppendTest
,
multiplePage
)
{
sr
and
(
0
);
taosSeedR
and
(
0
);
std
::
vector
<
int
>
v
;
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
v
.
push_back
(
r
and
());
v
.
push_back
(
taosR
and
());
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
...
...
@@ -202,10 +202,10 @@ TEST_F(TqMetaUpdateAppendTest, multiplePage) {
}
TEST_F
(
TqMetaUpdateAppendTest
,
multipleRewrite
)
{
sr
and
(
0
);
taosSeedR
and
(
0
);
std
::
vector
<
int
>
v
;
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
v
.
push_back
(
r
and
());
v
.
push_back
(
taosR
and
());
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
...
...
@@ -213,14 +213,14 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
for
(
int
i
=
0
;
i
<
500
;
i
++
)
{
tqHandleCommit
(
pMeta
,
i
);
v
[
i
]
=
r
and
();
v
[
i
]
=
taosR
and
();
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
}
for
(
int
i
=
500
;
i
<
1000
;
i
++
)
{
v
[
i
]
=
r
and
();
v
[
i
]
=
taosR
and
();
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
...
...
@@ -235,7 +235,7 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
ASSERT
(
pMeta
);
for
(
int
i
=
500
;
i
<
1000
;
i
++
)
{
v
[
i
]
=
r
and
();
v
[
i
]
=
taosR
and
();
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
...
...
@@ -250,10 +250,10 @@ TEST_F(TqMetaUpdateAppendTest, multipleRewrite) {
}
TEST_F
(
TqMetaUpdateAppendTest
,
dupCommit
)
{
sr
and
(
0
);
taosSeedR
and
(
0
);
std
::
vector
<
int
>
v
;
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
v
.
push_back
(
r
and
());
v
.
push_back
(
taosR
and
());
Foo
foo
;
foo
.
a
=
v
[
i
];
tqHandleCopyPut
(
pMeta
,
i
,
&
foo
,
sizeof
(
Foo
));
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
c6de1967
...
...
@@ -723,7 +723,7 @@ void *ctgTestGetDbVgroupThread(void *param) {
}
if
(
ctgTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
ctgTestPrintNum
==
0
)
{
printf
(
"Get:%d
\n
"
,
n
);
...
...
@@ -747,7 +747,7 @@ void *ctgTestSetSameDbVgroupThread(void *param) {
}
if
(
ctgTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
ctgTestPrintNum
==
0
)
{
printf
(
"Set:%d
\n
"
,
n
);
...
...
@@ -771,7 +771,7 @@ void *ctgTestSetDiffDbVgroupThread(void *param) {
}
if
(
ctgTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
ctgTestPrintNum
==
0
)
{
printf
(
"Set:%d
\n
"
,
n
);
...
...
@@ -801,7 +801,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
tfree
(
tbMeta
);
if
(
ctgTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
ctgTestPrintNum
==
0
)
{
...
...
@@ -838,7 +838,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
}
if
(
ctgTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
ctgTestPrintNum
==
0
)
{
printf
(
"Set:%d
\n
"
,
n
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
c6de1967
...
...
@@ -61,7 +61,7 @@ typedef enum SResultTsInterpType {
#if 0
static UNUSED_FUNC void *u_malloc (size_t __size) {
uint32_t v =
r
and();
uint32_t v =
taosR
and();
if (v % 1000 <= 0) {
return NULL;
...
...
@@ -71,7 +71,7 @@ static UNUSED_FUNC void *u_malloc (size_t __size) {
}
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
uint32_t v =
r
and();
uint32_t v =
taosR
and();
if (v % 1000 <= 0) {
return NULL;
} else {
...
...
@@ -80,7 +80,7 @@ static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
}
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
uint32_t v =
r
and();
uint32_t v =
taosR
and();
if (v % 5 <= 1) {
return NULL;
} else {
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
c6de1967
...
...
@@ -869,7 +869,7 @@ TEST(testCase, external_sort_Test) {
#if 0
su* v = static_cast<su*>(calloc(1000000, sizeof(su)));
for(int32_t i = 0; i < 1000000; ++i) {
v[i].v =
r
and();
v[i].v =
taosR
and();
v[i].c = static_cast<char*>(malloc(4));
*(int32_t*) v[i].c = i;
}
...
...
@@ -882,7 +882,7 @@ TEST(testCase, external_sort_Test) {
return;
#endif
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
SArray
*
pOrderVal
=
taosArrayInit
(
4
,
sizeof
(
SOrder
));
SOrder
o
=
{
0
};
...
...
@@ -943,7 +943,7 @@ TEST(testCase, external_sort_Test) {
}
TEST
(
testCase
,
sorted_merge_Test
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
SArray
*
pOrderVal
=
taosArrayInit
(
4
,
sizeof
(
SOrder
));
SOrder
o
=
{
0
};
...
...
@@ -1015,7 +1015,7 @@ TEST(testCase, sorted_merge_Test) {
}
TEST
(
testCase
,
time_interval_Operator_Test
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
SArray
*
pOrderVal
=
taosArrayInit
(
4
,
sizeof
(
SOrder
));
SOrder
o
=
{
0
};
...
...
source/libs/executor/test/lhashTests.cpp
浏览文件 @
c6de1967
...
...
@@ -25,7 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
TEST
(
testCase
,
linear_hash_Tests
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
_hash_fn_t
fn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
);
#if 0
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
c6de1967
...
...
@@ -699,7 +699,7 @@ class IndexObj {
for
(
int
i
=
0
;
i
<
numOfTable
;
i
++
)
{
for
(
int
k
=
0
;
k
<
10
&&
k
<
colVal
.
size
();
k
++
)
{
// opt
tColVal
[
r
and
()
%
colValSize
]
=
'a'
+
k
%
26
;
tColVal
[
taosR
and
()
%
colValSize
]
=
'a'
+
k
%
26
;
}
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
tColVal
.
c_str
(),
tColVal
.
size
());
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
c6de1967
...
...
@@ -266,7 +266,7 @@ int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, struct SSubplan* pPlan, qTas
int32_t
idx
=
abs
((
++
qwtTestCaseIdx
)
%
qwtTestCaseNum
);
qwtTestSinkBlockNum
=
0
;
qwtTestSinkMaxBlockNum
=
r
and
()
%
100
+
1
;
qwtTestSinkMaxBlockNum
=
taosR
and
()
%
100
+
1
;
qwtTestSinkQueryEnd
=
false
;
if
(
0
==
idx
)
{
...
...
@@ -295,15 +295,15 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
}
else
{
if
(
qwtTestSinkQueryEnd
)
{
*
pRes
=
NULL
;
*
useconds
=
r
and
()
%
10
;
*
useconds
=
taosR
and
()
%
10
;
return
0
;
}
endExec
=
r
and
()
%
5
;
endExec
=
taosR
and
()
%
5
;
int32_t
runTime
=
0
;
if
(
qwtTestEnableSleep
&&
qwtTestMaxExecTaskUsec
>
0
)
{
runTime
=
r
and
()
%
qwtTestMaxExecTaskUsec
;
runTime
=
taosR
and
()
%
qwtTestMaxExecTaskUsec
;
}
if
(
qwtTestEnableSleep
)
{
...
...
@@ -314,10 +314,10 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
if
(
endExec
)
{
*
pRes
=
(
SSDataBlock
*
)
calloc
(
1
,
sizeof
(
SSDataBlock
));
(
*
pRes
)
->
info
.
rows
=
r
and
()
%
1000
;
(
*
pRes
)
->
info
.
rows
=
taosR
and
()
%
1000
;
}
else
{
*
pRes
=
NULL
;
*
useconds
=
r
and
()
%
10
;
*
useconds
=
taosR
and
()
%
10
;
}
}
...
...
@@ -376,7 +376,7 @@ void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
taosWLockLatch
(
&
qwtTestSinkLock
);
if
(
qwtTestSinkBlockNum
>
0
)
{
*
pLen
=
r
and
()
%
100
+
1
;
*
pLen
=
taosR
and
()
%
100
+
1
;
qwtTestSinkBlockNum
--
;
}
else
{
*
pLen
=
0
;
...
...
@@ -392,7 +392,7 @@ void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) {
int32_t
qwtGetDataBlock
(
DataSinkHandle
handle
,
SOutputData
*
pOutput
)
{
taosWLockLatch
(
&
qwtTestSinkLock
);
if
(
qwtTestSinkLastLen
>
0
)
{
pOutput
->
numOfRows
=
r
and
()
%
10
+
1
;
pOutput
->
numOfRows
=
taosR
and
()
%
10
+
1
;
pOutput
->
compressed
=
1
;
pOutput
->
queryEnd
=
qwtTestSinkQueryEnd
;
if
(
qwtTestSinkBlockNum
==
0
)
{
...
...
@@ -402,7 +402,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
}
else
{
pOutput
->
bufStatus
=
DS_BUF_FULL
;
}
pOutput
->
useconds
=
r
and
()
%
10
+
1
;
pOutput
->
useconds
=
taosR
and
()
%
10
+
1
;
pOutput
->
precision
=
1
;
}
else
if
(
qwtTestSinkLastLen
==
0
)
{
pOutput
->
numOfRows
=
0
;
...
...
@@ -416,7 +416,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
}
else
{
pOutput
->
bufStatus
=
DS_BUF_FULL
;
}
pOutput
->
useconds
=
r
and
()
%
10
+
1
;
pOutput
->
useconds
=
taosR
and
()
%
10
+
1
;
pOutput
->
precision
=
1
;
}
else
{
assert
(
0
);
...
...
@@ -590,7 +590,7 @@ void *queryThread(void *param) {
qwtBuildQueryReqMsg
(
&
queryRpc
);
qWorkerProcessQueryMsg
(
mockPointer
,
mgmt
,
&
queryRpc
);
if
(
qwtTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
qwtTestPrintNum
==
0
)
{
printf
(
"query:%d
\n
"
,
n
);
...
...
@@ -612,7 +612,7 @@ void *readyThread(void *param) {
qwtBuildReadyReqMsg
(
&
readyMsg
,
&
readyRpc
);
code
=
qWorkerProcessReadyMsg
(
mockPointer
,
mgmt
,
&
readyRpc
);
if
(
qwtTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
qwtTestPrintNum
==
0
)
{
printf
(
"ready:%d
\n
"
,
n
);
...
...
@@ -634,7 +634,7 @@ void *fetchThread(void *param) {
qwtBuildFetchReqMsg
(
&
fetchMsg
,
&
fetchRpc
);
code
=
qWorkerProcessFetchMsg
(
mockPointer
,
mgmt
,
&
fetchRpc
);
if
(
qwtTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
qwtTestPrintNum
==
0
)
{
printf
(
"fetch:%d
\n
"
,
n
);
...
...
@@ -656,7 +656,7 @@ void *dropThread(void *param) {
qwtBuildDropReqMsg
(
&
dropMsg
,
&
dropRpc
);
code
=
qWorkerProcessDropMsg
(
mockPointer
,
mgmt
,
&
dropRpc
);
if
(
qwtTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
qwtTestPrintNum
==
0
)
{
printf
(
"drop:%d
\n
"
,
n
);
...
...
@@ -678,7 +678,7 @@ void *statusThread(void *param) {
qwtBuildStatusReqMsg
(
&
statusMsg
,
&
statusRpc
);
code
=
qWorkerProcessStatusMsg
(
mockPointer
,
mgmt
,
&
statusRpc
);
if
(
qwtTestEnableSleep
)
{
usleep
(
r
and
()
%
5
);
usleep
(
taosR
and
()
%
5
);
}
if
(
++
n
%
qwtTestPrintNum
==
0
)
{
printf
(
"status:%d
\n
"
,
n
);
...
...
@@ -748,7 +748,7 @@ void *queryQueueThread(void *param) {
if
(
qwtTestEnableSleep
&&
qwtTestReqMaxDelayUsec
>
0
)
{
int32_t
delay
=
r
and
()
%
qwtTestReqMaxDelayUsec
;
int32_t
delay
=
taosR
and
()
%
qwtTestReqMaxDelayUsec
;
if
(
delay
)
{
usleep
(
delay
);
...
...
@@ -804,7 +804,7 @@ void *fetchQueueThread(void *param) {
taosWUnLockLatch
(
&
qwtTestFetchQueueLock
);
if
(
qwtTestEnableSleep
&&
qwtTestReqMaxDelayUsec
>
0
)
{
int32_t
delay
=
r
and
()
%
qwtTestReqMaxDelayUsec
;
int32_t
delay
=
taosR
and
()
%
qwtTestReqMaxDelayUsec
;
if
(
delay
)
{
usleep
(
delay
);
...
...
@@ -963,7 +963,7 @@ TEST(seqTest, randCase) {
stubSetRpcSendResponse();
stubSetCreateExecTask();
sr
and(time(NULL));
taosSeedR
and(time(NULL));
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
ASSERT_EQ(code, 0);
...
...
@@ -971,7 +971,7 @@ TEST(seqTest, randCase) {
int32_t t = 0;
int32_t maxr = 10001;
while (true) {
int32_t r =
r
and() % maxr;
int32_t r =
taosR
and() % maxr;
if (r >= 0 && r < maxr/5) {
printf("Query,%d\n", t++);
...
...
@@ -1025,7 +1025,7 @@ TEST(seqTest, multithreadRand) {
stubSetStringToPlan();
stubSetRpcSendResponse();
sr
and(time(NULL));
taosSeedR
and(time(NULL));
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
ASSERT_EQ(code, 0);
...
...
@@ -1076,7 +1076,7 @@ TEST(rcTest, shortExecshortDelay) {
stubSetPutDataBlock
();
stubSetGetDataBlock
();
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
qwtTestStop
=
false
;
qwtTestQuitThreadNum
=
0
;
...
...
@@ -1157,7 +1157,7 @@ TEST(rcTest, longExecshortDelay) {
stubSetPutDataBlock
();
stubSetGetDataBlock
();
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
qwtTestStop
=
false
;
qwtTestQuitThreadNum
=
0
;
...
...
@@ -1240,7 +1240,7 @@ TEST(rcTest, shortExeclongDelay) {
stubSetPutDataBlock
();
stubSetGetDataBlock
();
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
qwtTestStop
=
false
;
qwtTestQuitThreadNum
=
0
;
...
...
@@ -1324,7 +1324,7 @@ TEST(rcTest, dropTest) {
stubSetPutDataBlock();
stubSetGetDataBlock();
sr
and(time(NULL));
taosSeedR
and(time(NULL));
code = qWorkerInit(NODE_TYPE_VNODE, 1, NULL, &mgmt, mockPointer, qwtPutReqToQueue);
ASSERT_EQ(code, 0);
...
...
@@ -1358,7 +1358,7 @@ TEST(rcTest, dropTest) {
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
...
...
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
c6de1967
...
...
@@ -1286,7 +1286,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) {
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
c6de1967
...
...
@@ -1427,7 +1427,7 @@ TEST(columnTest, greater_and_lower) {
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
c6de1967
...
...
@@ -532,7 +532,7 @@ void* schtRunJobThread(void *aa) {
void
*
schtFreeJobThread
(
void
*
aa
)
{
while
(
!
schtTestStop
)
{
usleep
(
r
and
()
%
100
);
usleep
(
taosR
and
()
%
100
);
schtFreeQueryJob
(
1
);
}
}
...
...
@@ -713,7 +713,7 @@ TEST(multiThread, forceFree) {
}
int
main
(
int
argc
,
char
**
argv
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
...
...
source/libs/sync/src/syncEnv.c
浏览文件 @
c6de1967
...
...
@@ -28,7 +28,7 @@ static void doSyncEnvStopTimer(SSyncEnv *pSyncEnv, tmr_h *pTimer);
int32_t
syncEnvStart
()
{
int32_t
ret
;
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
gSyncEnv
=
(
SSyncEnv
*
)
malloc
(
sizeof
(
SSyncEnv
));
assert
(
gSyncEnv
!=
NULL
);
ret
=
doSyncEnvStart
(
gSyncEnv
);
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
c6de1967
...
...
@@ -44,7 +44,7 @@ int32_t syncIOStart(char *host, uint16_t port) {
gSyncIO
=
syncIOCreate
(
host
,
port
);
assert
(
gSyncIO
!=
NULL
);
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
int32_t
ret
=
syncIOStartInternal
(
gSyncIO
);
assert
(
ret
==
0
);
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
c6de1967
...
...
@@ -95,7 +95,7 @@ void syncUtilbufCopyDeep(const SSyncBuffer* src, SSyncBuffer* dest) {
// ---- misc ----
int32_t
syncUtilRand
(
int32_t
max
)
{
return
r
and
()
%
max
;
}
int32_t
syncUtilRand
(
int32_t
max
)
{
return
taosR
and
()
%
max
;
}
int32_t
syncUtilElectRandomMS
()
{
return
ELECT_TIMER_MS_MIN
+
syncUtilRand
(
ELECT_TIMER_MS_RANGE
);
}
...
...
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
c6de1967
...
...
@@ -27,7 +27,7 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
((
uint64_t
*
)
fileid
)[
0
]
=
stDev
;
((
uint64_t
*
)
fileid
)[
1
]
=
stIno
;
if
(
unique
)
{
((
uint64_t
*
)
fileid
)[
2
]
=
r
and
();
((
uint64_t
*
)
fileid
)[
2
]
=
taosR
and
();
}
return
0
;
...
...
source/libs/transport/src/rpcMain.c
浏览文件 @
c6de1967
...
...
@@ -749,7 +749,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
memcpy
(
pConn
->
user
,
pHead
->
user
,
tListLen
(
pConn
->
user
));
pConn
->
pRpc
=
pRpc
;
pConn
->
sid
=
sid
;
pConn
->
tranId
=
(
uint16_t
)(
r
and
()
&
0xFFFF
);
pConn
->
tranId
=
(
uint16_t
)(
taosR
and
()
&
0xFFFF
);
pConn
->
ownId
=
htonl
(
pConn
->
sid
);
pConn
->
linkUid
=
pHead
->
linkUid
;
if
(
pRpc
->
afp
)
{
...
...
source/libs/wal/test/walMetaTest.cpp
浏览文件 @
c6de1967
...
...
@@ -300,7 +300,7 @@ TEST_F(WalKeepEnv, readHandleRead) {
ASSERT_EQ
(
code
,
0
);
}
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
int
ver
=
r
and
()
%
100
;
int
ver
=
taosR
and
()
%
100
;
code
=
walReadWithHandle
(
pRead
,
ver
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -352,7 +352,7 @@ TEST_F(WalRetentionEnv, repairMeta1) {
ASSERT
(
pRead
!=
NULL
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
int
ver
=
r
and
()
%
100
;
int
ver
=
taosR
and
()
%
100
;
code
=
walReadWithHandle
(
pRead
,
ver
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -382,7 +382,7 @@ TEST_F(WalRetentionEnv, repairMeta1) {
}
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
int
ver
=
r
and
()
%
200
;
int
ver
=
taosR
and
()
%
200
;
code
=
walReadWithHandle
(
pRead
,
ver
);
ASSERT_EQ
(
code
,
0
);
...
...
source/os/src/osEnv.c
浏览文件 @
c6de1967
...
...
@@ -38,7 +38,7 @@ float tsNumOfCores = 0;
int64_t
tsTotalMemoryKB
=
0
;
void
osInit
()
{
sr
and
(
taosSafeRand
());
taosSeedR
and
(
taosSafeRand
());
taosGetSystemLocale
(
tsLocale
,
tsCharset
);
taosGetSystemTimezone
(
tsTimezone
);
taosSetSystemTimezone
(
tsTimezone
,
tsTimezone
,
&
tsDaylight
);
...
...
source/os/src/osRand.c
浏览文件 @
c6de1967
...
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define ALLOW_FORBID_FUNC
#define _DEFAULT_SOURCE
#include "os.h"
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
...
...
@@ -21,8 +21,12 @@
#include <unistd.h>
#endif
void
taosSeedRand
(
uint32_t
seed
)
{
return
srand
(
seed
);
}
uint32_t
taosRand
(
void
)
{
return
rand
();
}
uint32_t
taosRandR
(
uint32_t
*
pSeed
)
{
return
rand_r
(
pSeed
);
}
uint32_t
taosSafeRand
(
void
)
{
TdFilePtr
pFile
;
int
seed
;
...
...
source/util/src/tdes.c
浏览文件 @
c6de1967
...
...
@@ -32,7 +32,7 @@ void process_message(uint8_t* message_piece, uint8_t* processed_piece, key_set*
#if 0
int64_t taosDesGenKey() {
uint32_t iseed = (uint32_t)time(NULL);
sr
and(iseed);
taosSeedR
and(iseed);
uint8_t key[8] = {0};
generate_key(key);
...
...
source/util/src/tskiplist.c
浏览文件 @
c6de1967
...
...
@@ -51,7 +51,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
pSkipList
->
len
=
keyLen
;
pSkipList
->
flags
=
flags
;
pSkipList
->
keyFn
=
fn
;
pSkipList
->
seed
=
r
and
();
pSkipList
->
seed
=
taosR
and
();
#if 0
// the function getkeycomparfunc is defined in common
...
...
@@ -82,7 +82,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
}
}
sr
and
((
uint32_t
)
time
(
NULL
));
taosSeedR
and
((
uint32_t
)
time
(
NULL
));
#if SKIP_LIST_RECORD_PERFORMANCE
pSkipList
->
state
.
nTotalMemSize
+=
sizeof
(
SSkipList
);
...
...
@@ -560,9 +560,9 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
int32_t
n
=
1
;
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
while
((
r
and
()
%
factor
)
==
0
&&
n
<=
pSkipList
->
maxLevel
)
{
while
((
taosR
and
()
%
factor
)
==
0
&&
n
<=
pSkipList
->
maxLevel
)
{
#else
while
((
rand_r
(
&
(
pSkipList
->
seed
))
%
factor
)
==
0
&&
n
<=
pSkipList
->
maxLevel
)
{
while
((
taosRandR
(
&
(
pSkipList
->
seed
))
%
factor
)
==
0
&&
n
<=
pSkipList
->
maxLevel
)
{
#endif
n
++
;
}
...
...
source/util/test/codingTests.cpp
浏览文件 @
c6de1967
...
...
@@ -150,7 +150,7 @@ static bool test_variant_int64(int64_t value) {
}
TEST
(
codingTest
,
fixed_encode_decode
)
{
sr
and
(
time
(
0
));
taosSeedR
and
(
time
(
0
));
// uint16_t
for
(
uint16_t
value
=
0
;
value
<=
UINT16_MAX
;
value
++
)
{
...
...
@@ -204,7 +204,7 @@ TEST(codingTest, fixed_encode_decode) {
}
TEST
(
codingTest
,
variant_encode_decode
)
{
sr
and
(
time
(
0
));
taosSeedR
and
(
time
(
0
));
// uint16_t
for
(
uint16_t
value
=
0
;
value
<=
UINT16_MAX
;
value
++
)
{
...
...
source/util/test/pageBufferTest.cpp
浏览文件 @
c6de1967
...
...
@@ -161,7 +161,7 @@ void recyclePageTest() {
TEST
(
testCase
,
resultBufferTest
)
{
sr
and
(
time
(
NULL
));
taosSeedR
and
(
time
(
NULL
));
simpleTest
();
writeDownTest
();
recyclePageTest
();
...
...
source/util/test/skiplistTest.cpp
浏览文件 @
c6de1967
...
...
@@ -47,7 +47,7 @@ void doubleSkipListTest() {
SSkipListKey sk;
for (int32_t i = 0; i < 100; ++i) {
sk.nType = TSDB_DATA_TYPE_DOUBLE;
int32_t idx = abs((i *
r
and()) % 1000);
int32_t idx = abs((i *
taosR
and()) % 1000);
sk.dKey = doubleVal[idx];
...
...
@@ -74,7 +74,7 @@ void randKeyTest() {
false, getkey);
int32_t size = 200000;
sr
and(time(NULL));
taosSeedR
and(time(NULL));
printf("generated %d keys is: \n", size);
...
...
@@ -87,7 +87,7 @@ void randKeyTest() {
d->level = level;
int32_t* key = (int32_t*)SL_GET_NODE_KEY(pSkipList, d);
key[0] =
r
and() % 1000000000;
key[0] =
taosR
and() % 1000000000;
key[1] = key[0];
...
...
@@ -337,7 +337,7 @@ void duplicatedKeyTest() {
TEST(testCase, skiplist_test) {
assert(sizeof(SSkipListKey) == 8);
sr
and(time(NULL));
taosSeedR
and(time(NULL));
stringKeySkiplistTest();
doubleSkipListTest();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录