提交 651b3971 编写于 作者: wafwerar's avatar wafwerar

[TD-13766]<fix>: redefine sleep api.

上级 f0445edf
......@@ -20,7 +20,17 @@
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 Sleep SLEEP_FUNC_TAOS_FORBID
#define sleep SLEEP_FUNC_TAOS_FORBID
#define usleep USLEEP_FUNC_TAOS_FORBID
#define nanosleep NANOSLEEP_FUNC_TAOS_FORBID
#endif
void taosSsleep(int32_t s);
void taosMsleep(int32_t ms);
void taosUsleep(int32_t us);
#ifdef __cplusplus
}
......
......@@ -449,7 +449,7 @@ static void hbStopThread() {
}
while (2 != atomic_load_8(&clientHbMgr.threadStop)) {
usleep(10);
taosUsleep(10);
}
tscDebug("hb thread stopped");
......
......@@ -1146,13 +1146,13 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
if (taosArrayGetSize(tmq->clientTopics) == 0) {
tscDebug("consumer:%ld poll but not assigned", tmq->consumerId);
/*printf("over1\n");*/
usleep(blocking_time * 1000);
taosMsleep(blocking_time);
return NULL;
}
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, tmq->nextTopicIdx);
if (taosArrayGetSize(pTopic->vgs) == 0) {
/*printf("over2\n");*/
usleep(blocking_time * 1000);
taosMsleep(blocking_time);
return NULL;
}
......@@ -1165,14 +1165,14 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, blocking_time, pTopic, pVg);
if (pReq == NULL) {
ASSERT(false);
usleep(blocking_time * 1000);
taosMsleep(blocking_time);
return NULL;
}
SMqPollCbParam* param = malloc(sizeof(SMqPollCbParam));
if (param == NULL) {
ASSERT(false);
usleep(blocking_time * 1000);
taosMsleep(blocking_time);
return NULL;
}
param->tmq = tmq;
......@@ -1204,7 +1204,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
if (tmq_message == NULL) {
if (beginVgIdx == pTopic->nextVgIdx) {
usleep(blocking_time * 1000);
taosMsleep(blocking_time);
} else {
continue;
}
......
......@@ -2635,7 +2635,7 @@ void catalogDestroy(void) {
tsem_post(&gCtgMgmt.sem);
while (CTG_IS_LOCKED(&gCtgMgmt.lock)) {
usleep(1);
taosUsleep(1);
}
CTG_LOCK(CTG_WRITE, &gCtgMgmt.lock);
......
......@@ -723,7 +723,7 @@ void *ctgTestGetDbVgroupThread(void *param) {
}
if (ctgTestEnableSleep) {
usleep(taosRand() % 5);
taosUsleep(taosRand() % 5);
}
if (++n % ctgTestPrintNum == 0) {
printf("Get:%d\n", n);
......@@ -747,7 +747,7 @@ void *ctgTestSetSameDbVgroupThread(void *param) {
}
if (ctgTestEnableSleep) {
usleep(taosRand() % 5);
taosUsleep(taosRand() % 5);
}
if (++n % ctgTestPrintNum == 0) {
printf("Set:%d\n", n);
......@@ -771,7 +771,7 @@ void *ctgTestSetDiffDbVgroupThread(void *param) {
}
if (ctgTestEnableSleep) {
usleep(taosRand() % 5);
taosUsleep(taosRand() % 5);
}
if (++n % ctgTestPrintNum == 0) {
printf("Set:%d\n", n);
......@@ -801,7 +801,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
tfree(tbMeta);
if (ctgTestEnableSleep) {
usleep(taosRand() % 5);
taosUsleep(taosRand() % 5);
}
if (++n % ctgTestPrintNum == 0) {
......@@ -838,7 +838,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
}
if (ctgTestEnableSleep) {
usleep(taosRand() % 5);
taosUsleep(taosRand() % 5);
}
if (++n % ctgTestPrintNum == 0) {
printf("Set:%d\n", n);
......@@ -880,7 +880,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ(vgInfo.epSet.numOfEps, 3);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) {
usleep(50000);
taosMsleep(50);
}
ctgTestSetRspTableMeta();
......@@ -901,7 +901,7 @@ TEST(tableMeta, normalTable) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (0 == n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -949,7 +949,7 @@ TEST(tableMeta, normalTable) {
allDbNum += dbNum;
allStbNum += stbNum;
sleep(2);
taosSsleep(2);
}
ASSERT_EQ(allDbNum, 1);
......@@ -996,7 +996,7 @@ TEST(tableMeta, childTableCase) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (0 == n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1058,7 +1058,7 @@ TEST(tableMeta, childTableCase) {
allDbNum += dbNum;
allStbNum += stbNum;
sleep(2);
taosSsleep(2);
}
ASSERT_EQ(allDbNum, 1);
......@@ -1105,7 +1105,7 @@ TEST(tableMeta, superTableCase) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (0 == n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1132,7 +1132,7 @@ TEST(tableMeta, superTableCase) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (2 != n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1181,7 +1181,7 @@ TEST(tableMeta, superTableCase) {
allDbNum += dbNum;
allStbNum += stbNum;
sleep(2);
taosSsleep(2);
}
ASSERT_EQ(allDbNum, 1);
......@@ -1230,7 +1230,7 @@ TEST(tableMeta, rmStbMeta) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (0 == n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1244,7 +1244,7 @@ TEST(tableMeta, rmStbMeta) {
int32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
int32_t m = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM);
if (n || m) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1300,7 +1300,7 @@ TEST(tableMeta, updateStbMeta) {
while (true) {
uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM);
if (0 == n) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1320,7 +1320,7 @@ TEST(tableMeta, updateStbMeta) {
uint64_t n = 0;
ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n);
if (n != 3) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -1392,7 +1392,7 @@ TEST(refreshGetMeta, normal2normal) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1410,7 +1410,7 @@ TEST(refreshGetMeta, normal2normal) {
tfree(tableMeta);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
code = catalogRefreshGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta, 0);
......@@ -1471,7 +1471,7 @@ TEST(refreshGetMeta, normal2notexist) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1489,7 +1489,7 @@ TEST(refreshGetMeta, normal2notexist) {
tfree(tableMeta);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
code = catalogRefreshGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta, 0);
......@@ -1545,7 +1545,7 @@ TEST(refreshGetMeta, normal2child) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1563,7 +1563,7 @@ TEST(refreshGetMeta, normal2child) {
tfree(tableMeta);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
code = catalogRefreshGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta, 0);
......@@ -1629,7 +1629,7 @@ TEST(refreshGetMeta, stable2child) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1648,7 +1648,7 @@ TEST(refreshGetMeta, stable2child) {
tfree(tableMeta);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
ctgTestCurrentSTableName = ctgTestSTablename;
......@@ -1714,7 +1714,7 @@ TEST(refreshGetMeta, stable2stable) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1733,7 +1733,7 @@ TEST(refreshGetMeta, stable2stable) {
tfree(tableMeta);
while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
code = catalogRefreshGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta, 0);
......@@ -1802,7 +1802,7 @@ TEST(refreshGetMeta, child2stable) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
STableMeta *tableMeta = NULL;
......@@ -1819,7 +1819,7 @@ TEST(refreshGetMeta, child2stable) {
tfree(tableMeta);
while (2 != ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) {
usleep(50000);
taosMsleep(50);
}
ctgTestCurrentSTableName = ctgTestTablename;
......@@ -2019,7 +2019,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
if (n > 0) {
break;
}
usleep(50000);
taosMsleep(50);
}
code = catalogGetTableHashVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &vgInfo);
......@@ -2043,7 +2043,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
uint64_t n = 0;
ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n);
if (n != 3) {
usleep(50000);
taosMsleep(50);
} else {
break;
}
......@@ -2100,20 +2100,20 @@ TEST(multiThread, getSetRmSameDbVgroup) {
pthread_t thread1, thread2;
pthread_create(&(thread1), &thattr, ctgTestSetSameDbVgroupThread, pCtg);
sleep(1);
taosSsleep(1);
pthread_create(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg);
while (true) {
if (ctgTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(ctgTestMTRunSec);
taosSsleep(ctgTestMTRunSec);
break;
}
}
ctgTestStop = true;
sleep(1);
taosSsleep(1);
catalogDestroy();
memset(&gCtgMgmt, 0, sizeof(gCtgMgmt));
......@@ -2152,20 +2152,20 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
pthread_t thread1, thread2;
pthread_create(&(thread1), &thattr, ctgTestSetDiffDbVgroupThread, pCtg);
sleep(1);
taosSsleep(1);
pthread_create(&(thread2), &thattr, ctgTestGetDbVgroupThread, pCtg);
while (true) {
if (ctgTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(ctgTestMTRunSec);
taosSsleep(ctgTestMTRunSec);
break;
}
}
ctgTestStop = true;
sleep(1);
taosSsleep(1);
catalogDestroy();
memset(&gCtgMgmt, 0, sizeof(gCtgMgmt));
......@@ -2203,20 +2203,20 @@ TEST(multiThread, ctableMeta) {
pthread_t thread1, thread2;
pthread_create(&(thread1), &thattr, ctgTestSetCtableMetaThread, pCtg);
sleep(1);
taosSsleep(1);
pthread_create(&(thread1), &thattr, ctgTestGetCtableMetaThread, pCtg);
while (true) {
if (ctgTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(ctgTestMTRunSec);
taosSsleep(ctgTestMTRunSec);
break;
}
}
ctgTestStop = true;
sleep(2);
taosSsleep(2);
catalogDestroy();
memset(&gCtgMgmt, 0, sizeof(gCtgMgmt));
......@@ -2267,7 +2267,7 @@ TEST(rentTest, allRent) {
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
while (ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM) < i) {
usleep(50000);
taosMsleep(50);
}
code = catalogGetExpiredDBs(pCtg, &dbs, &num);
......@@ -2292,7 +2292,7 @@ TEST(rentTest, allRent) {
}
printf("*************************************************\n");
sleep(2);
taosSsleep(2);
}
catalogDestroy();
......
......@@ -63,7 +63,7 @@ int main(int argc, char** argv) {
TEST(testCase, async_task_test) {
SParam* p = (SParam*)calloc(1, sizeof(SParam));
taosAsyncExec(testPrint, p, NULL);
usleep(5000);
taosMsleep(5);
}
TEST(testCase, many_async_task_test) {
......@@ -73,14 +73,14 @@ TEST(testCase, many_async_task_test) {
taosAsyncExec(testPrint, p, NULL);
}
usleep(10000);
taosMsleep(10);
}
TEST(testCase, error_in_async_test) {
int32_t code = 0;
SParam* p = (SParam*) calloc(1, sizeof(SParam));
taosAsyncExec(testPrintError, p, &code);
usleep(1000);
taosMsleep(1);
printf("Error code:%d after asynchronously exec function\n", code);
}
......
......@@ -308,7 +308,7 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
if (qwtTestEnableSleep) {
if (runTime) {
usleep(runTime);
taosUsleep(runTime);
}
}
......@@ -590,7 +590,7 @@ void *queryThread(void *param) {
qwtBuildQueryReqMsg(&queryRpc);
qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc);
if (qwtTestEnableSleep) {
usleep(taosRand()%5);
taosUsleep(taosRand()%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(taosRand()%5);
taosUsleep(taosRand()%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(taosRand()%5);
taosUsleep(taosRand()%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(taosRand()%5);
taosUsleep(taosRand()%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(taosRand()%5);
taosUsleep(taosRand()%5);
}
if (++n % qwtTestPrintNum == 0) {
printf("status:%d\n", n);
......@@ -696,7 +696,7 @@ void *qwtclientThread(void *param) {
void *mockPointer = (void *)0x1;
SRpcMsg queryRpc = {0};
sleep(1);
taosSsleep(1);
while (!qwtTestStop) {
qwtTestCaseFinished = false;
......@@ -705,7 +705,7 @@ void *qwtclientThread(void *param) {
qwtPutReqToQueue((void *)0x1, &queryRpc);
while (!qwtTestCaseFinished) {
usleep(1);
taosUsleep(1);
}
......@@ -751,7 +751,7 @@ void *queryQueueThread(void *param) {
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
if (delay) {
usleep(delay);
taosUsleep(delay);
}
}
......@@ -807,7 +807,7 @@ void *fetchQueueThread(void *param) {
int32_t delay = taosRand() % qwtTestReqMaxDelayUsec;
if (delay) {
usleep(delay);
taosUsleep(delay);
}
}
......@@ -982,21 +982,21 @@ TEST(seqTest, randCase) {
qwtBuildReadyReqMsg(&readyMsg, &readyRpc);
code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc);
if (qwtTestEnableSleep) {
usleep(1);
taosUsleep(1);
}
} else if (r >= maxr * 2/5 && r < maxr* 3/5) {
printf("Fetch,%d\n", t++);
qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc);
code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc);
if (qwtTestEnableSleep) {
usleep(1);
taosUsleep(1);
}
} else if (r >= maxr * 3/5 && r < maxr * 4/5) {
printf("Drop,%d\n", t++);
qwtBuildDropReqMsg(&dropMsg, &dropRpc);
code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc);
if (qwtTestEnableSleep) {
usleep(1);
taosUsleep(1);
}
} else if (r >= maxr * 4/5 && r < maxr-1) {
printf("Status,%d\n", t++);
......@@ -1004,7 +1004,7 @@ TEST(seqTest, randCase) {
code = qWorkerProcessStatusMsg(mockPointer, mgmt, &statusRpc);
ASSERT_EQ(code, 0);
if (qwtTestEnableSleep) {
usleep(1);
taosUsleep(1);
}
} else {
printf("QUIT RAND NOW");
......@@ -1042,15 +1042,15 @@ TEST(seqTest, multithreadRand) {
while (true) {
if (qwtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(qwtTestMTRunSec);
taosSsleep(qwtTestMTRunSec);
break;
}
}
qwtTestStop = true;
sleep(3);
taosSsleep(3);
qWorkerDestroy(&mgmt);
}
......@@ -1099,9 +1099,9 @@ TEST(rcTest, shortExecshortDelay) {
while (true) {
if (qwtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(qwtTestMTRunSec);
taosSsleep(qwtTestMTRunSec);
break;
}
}
......@@ -1113,14 +1113,14 @@ TEST(rcTest, shortExecshortDelay) {
break;
}
sleep(1);
taosSsleep(1);
if (qwtTestCaseFinished) {
if (qwtTestQuitThreadNum < 3) {
tsem_post(&qwtTestQuerySem);
tsem_post(&qwtTestFetchSem);
usleep(10);
taosUsleep(10);
}
}
......@@ -1180,9 +1180,9 @@ TEST(rcTest, longExecshortDelay) {
while (true) {
if (qwtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(qwtTestMTRunSec);
taosSsleep(qwtTestMTRunSec);
break;
}
}
......@@ -1195,14 +1195,14 @@ TEST(rcTest, longExecshortDelay) {
break;
}
sleep(1);
taosSsleep(1);
if (qwtTestCaseFinished) {
if (qwtTestQuitThreadNum < 3) {
tsem_post(&qwtTestQuerySem);
tsem_post(&qwtTestFetchSem);
usleep(10);
taosUsleep(10);
}
}
......@@ -1263,9 +1263,9 @@ TEST(rcTest, shortExeclongDelay) {
while (true) {
if (qwtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(qwtTestMTRunSec);
taosSsleep(qwtTestMTRunSec);
break;
}
}
......@@ -1278,14 +1278,14 @@ TEST(rcTest, shortExeclongDelay) {
break;
}
sleep(1);
taosSsleep(1);
if (qwtTestCaseFinished) {
if (qwtTestQuitThreadNum < 3) {
tsem_post(&qwtTestQuerySem);
tsem_post(&qwtTestFetchSem);
usleep(10);
taosUsleep(10);
}
}
......@@ -1342,15 +1342,15 @@ TEST(rcTest, dropTest) {
while (true) {
if (qwtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(qwtTestMTRunSec);
taosSsleep(qwtTestMTRunSec);
break;
}
}
qwtTestStop = true;
sleep(3);
taosSsleep(3);
qWorkerDestroy(&mgmt);
}
......
......@@ -278,7 +278,7 @@ void *schtSendRsp(void *param) {
break;
}
usleep(1000);
taosMsleep(1);
}
pJob = schAcquireJob(job);
......@@ -303,7 +303,7 @@ void *schtCreateFetchRspThread(void *param) {
int64_t job = *(int64_t *)param;
SSchJob* pJob = schAcquireJob(job);
sleep(1);
taosSsleep(1);
int32_t code = 0;
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)calloc(1, sizeof(SRetrieveTableRsp));
......@@ -327,7 +327,7 @@ void *schtFetchRspThread(void *aa) {
continue;
}
usleep(1);
taosUsleep(1);
param = (SSchCallbackParam *)calloc(1, sizeof(*param));
......@@ -532,7 +532,7 @@ void* schtRunJobThread(void *aa) {
void* schtFreeJobThread(void *aa) {
while (!schtTestStop) {
usleep(taosRand() % 100);
taosUsleep(taosRand() % 100);
schtFreeQueryJob(1);
}
}
......@@ -701,15 +701,15 @@ TEST(multiThread, forceFree) {
while (true) {
if (schtTestDeadLoop) {
sleep(1);
taosSsleep(1);
} else {
sleep(schtTestMTRunSec);
taosSsleep(schtTestMTRunSec);
break;
}
}
schtTestStop = true;
sleep(3);
taosSsleep(3);
}
int main(int argc, char** argv) {
......
......@@ -39,11 +39,11 @@ int main() {
rpcMsg.msgType = 77;
syncIOSendMsg(gSyncIO->clientRpc, &epSet, &rpcMsg);
sleep(1);
taosSsleep(1);
}
while (1) {
sleep(1);
taosSsleep(1);
}
return 0;
......
......@@ -26,7 +26,7 @@ int main() {
assert(ret == 0);
while (1) {
sleep(1);
taosSsleep(1);
}
return 0;
......
......@@ -39,11 +39,11 @@ int main() {
rpcMsg.msgType = 77;
syncIOSendMsg(gSyncIO->clientRpc, &epSet, &rpcMsg);
sleep(1);
taosSsleep(1);
}
while (1) {
sleep(1);
taosSsleep(1);
}
return 0;
......
......@@ -29,7 +29,7 @@ int main() {
assert(ret == 0);
while (1) {
sleep(1);
taosSsleep(1);
}
return 0;
}
......@@ -29,7 +29,7 @@ int main() {
assert(ret == 0);
while (1) {
sleep(1);
taosSsleep(1);
}
return 0;
}
......@@ -107,7 +107,7 @@ static void *sendRequest(void *param) {
tDebug("recv response succefully");
// usleep(100000000);
// taosSsleep(100);
}
tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000);
......@@ -223,7 +223,7 @@ int main(int argc, char *argv[]) {
}
do {
usleep(1);
taosUsleep(1);
} while (tcount < appThreads);
gettimeofday(&systemTime, NULL);
......
......@@ -77,7 +77,7 @@ void processShellMsg() {
taosFreeQitem(pRpcMsg);
{
// sleep(1);
// taosSsleep(1);
SRpcMsg nRpcMsg = {0};
nRpcMsg.pCont = rpcMallocCont(msgSize);
nRpcMsg.contLen = msgSize;
......@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
tError("failed to start RPC server");
return -1;
}
// sleep(5);
// taosSsleep(5);
tInfo("RPC server is running, ctrl-c to exit");
......
......@@ -84,7 +84,7 @@ static void *sendRequest(void *param) {
tDebug("recv response succefully");
// usleep(100000000);
// taosSsleep(100);
}
tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000);
......@@ -200,7 +200,7 @@ int main(int argc, char *argv[]) {
}
do {
usleep(1);
taosUsleep(1);
} while (tcount < appThreads);
gettimeofday(&systemTime, NULL);
......
......@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
}
do {
usleep(1);
taosUsleep(1);
} while ( tcount < appThreads);
gettimeofday(&systemTime, NULL);
......
......@@ -85,7 +85,7 @@ static void *sendRequest(void *param) {
tDebug("recv response succefully");
// usleep(100000000);
// taosSsleep(100);
}
tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000);
......@@ -201,7 +201,7 @@ int main(int argc, char *argv[]) {
}
do {
usleep(1);
taosUsleep(1);
} while (tcount < appThreads);
gettimeofday(&systemTime, NULL);
......
......@@ -13,47 +13,35 @@
* 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)
void taosMsleep(int32_t ms) { Sleep(ms); }
#else
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#include <unistd.h>
#endif
/*
to make taosMsleep work,
signal SIGALRM shall be blocked in the calling thread,
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_BLOCK, &set, NULL);
*/
void taosMsleep(int32_t mseconds) {
#if 1
usleep(mseconds * 1000);
void taosSsleep(int32_t s) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
Sleep(1000 * s);
#else
struct timeval timeout;
int32_t seconds, useconds;
seconds = mseconds / 1000;
useconds = (mseconds % 1000) * 1000;
timeout.tv_sec = seconds;
timeout.tv_usec = useconds;
/* sigset_t set; */
/* sigemptyset(&set); */
/* sigaddset(&set, SIGALRM); */
/* pthread_sigmask(SIG_BLOCK, &set, NULL); */
select(0, NULL, NULL, NULL, &timeout);
sleep(s);
#endif
}
/* pthread_sigmask(SIG_UNBLOCK, &set, NULL); */
void taosMsleep(int32_t ms) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
Sleep(ms);
#else
usleep(ms * 1000);
#endif
}
void taosUsleep(int32_t us) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
nanosleep(1000 * us);
#else
usleep(us);
#endif
}
......@@ -291,11 +291,10 @@ int32_t twcslen(const wchar_t *wcs) {
return n;
}
int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) {
for (int32_t i = 0; i < bytes; ++i) {
int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i * 4);
int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i * 4);
for (int32_t i = 0; i < bytes; i += TSDB_NCHAR_SIZE) {
int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i);
int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i);
if ((f1 == 0 && f2 != 0) || (f1 != 0 && f2 == 0)) {
return f1 - f2;
......
......@@ -14,7 +14,7 @@ TEST(cacheTest, client_cache_test) {
char data1[] = "test11";
char* cachedObj = (char*) taosCachePut(tscMetaCache, key1, strlen(key1), data1, strlen(data1)+1, 1);
sleep(REFRESH_TIME_IN_SEC+1);
taosSsleep(REFRESH_TIME_IN_SEC+1);
printf("obj is still valid: %s\n", cachedObj);
......@@ -37,7 +37,7 @@ TEST(cacheTest, client_cache_test) {
taosCacheRelease(tscMetaCache, (void**) &cachedObj2, false);
sleep(3);
taosSsleep(3);
char* d = (char*) taosCacheAcquireByKey(tscMetaCache, key3, strlen(key3));
assert(d == NULL);
......
......@@ -42,7 +42,7 @@ void *addRef(void *param) {
pSpace->p[id] = malloc(128);
pSpace->rid[id] = taosAddRef(pSpace->rsetId, pSpace->p[id]);
}
usleep(100);
taosUsleep(100);
}
return NULL;
......@@ -60,7 +60,7 @@ void *removeRef(void *param) {
if (code == 0) pSpace->rid[id] = 0;
}
usleep(100);
taosUsleep(100);
}
return NULL;
......@@ -76,7 +76,7 @@ void *acquireRelease(void *param) {
id = random() % pSpace->refNum;
void *p = taosAcquireRef(pSpace->rsetId, (int64_t) pSpace->p[id]);
if (p) {
usleep(id % 5 + 1);
taosUsleep(id % 5 + 1);
taosReleaseRef(pSpace->rsetId, (int64_t) pSpace->p[id]);
}
}
......
......@@ -5089,7 +5089,7 @@ int main(int argc, char *argv[])
//pthread_create(&(pThreadList[3]), &thattr, runcase, (void *)&par[3]);
while(1) {
sleep(1);
taosSsleep(1);
}
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册