mirror of
https://gitee.com/openharmony/developtools_hdc
synced 2025-02-11 21:55:40 +00:00
hdc uv mntn
Signed-off-by: 李帅 <leo.lishuai@huawei.com>
This commit is contained in:
parent
1da9fe7d2a
commit
b3d3557143
@ -20,6 +20,7 @@ HdcChannelBase::HdcChannelBase(const bool serverOrClient, const string &addrStri
|
||||
SetChannelTCPString(addrString);
|
||||
isServerOrClient = serverOrClient;
|
||||
loopMain = loopMainIn;
|
||||
loopMainStatus.StartReportTimer();
|
||||
threadChanneMain = uv_thread_self();
|
||||
uv_rwlock_init(&mainAsync);
|
||||
uv_async_init(loopMain, &asyncMainLoop, MainAsyncCallback);
|
||||
|
@ -41,6 +41,7 @@ HdcSessionBase::HdcSessionBase(bool serverOrDaemonIn, size_t uvThreadSize) : loo
|
||||
setenv(uvThreadEnv.c_str(), uvThreadVal.c_str(), 1);
|
||||
#endif
|
||||
uv_loop_init(&loopMain);
|
||||
loopMainStatus.StartReportTimer();
|
||||
WRITE_LOG(LOG_DEBUG, "loopMain init");
|
||||
uv_rwlock_init(&mainAsync);
|
||||
#ifndef FUZZ_TEST
|
||||
@ -453,6 +454,7 @@ HSession HdcSessionBase::MallocSession(bool serverOrDaemon, const ConnType connT
|
||||
return nullptr;
|
||||
}
|
||||
uv_loop_init(&hSession->childLoop);
|
||||
childLoopStatus.StartReportTimer();
|
||||
hSession->uvHandleRef = 0;
|
||||
// pullup child
|
||||
WRITE_LOG(LOG_INFO, "HdcSessionBase NewSession, sessionId:%u, connType:%d.",
|
||||
|
@ -54,12 +54,12 @@ namespace Hdc {
|
||||
LoopStatus *ls = reinterpret_cast<LoopStatus *>(req->data);
|
||||
CALLSTAT_GUARD(*ls, req->loop, "LoopStatus::ReportTimerProc");
|
||||
}
|
||||
void LoopStatus::ReportOnce(uv_loop_t *loop)
|
||||
void LoopStatus::StartReportTimer(void)
|
||||
{
|
||||
uv_timer_t timer;
|
||||
uv_timer_init(loop, &timer);
|
||||
uv_timer_init(mLoop, &timer);
|
||||
timer.data = this;
|
||||
uv_timer_start(&timer, ReportTimerProc, 0, 0);
|
||||
uv_timer_start(&timer, ReportTimerProc, 0, 1 * MS_PER_SEC);
|
||||
}
|
||||
LoopStatus::LoopStatus(uv_loop_t *loop, const string &loopName) : mLoop(loop), mLoopName(loopName)
|
||||
{
|
||||
@ -130,11 +130,11 @@ namespace Hdc {
|
||||
|
||||
int GetLoopHungTimeout(void)
|
||||
{
|
||||
return 1 * US_PER_SEC;
|
||||
return US_PER_SEC / 2;
|
||||
}
|
||||
int GetLoopMonitorPeriod(void)
|
||||
{
|
||||
return 1 * MS_PER_SEC;
|
||||
return 3 * MS_PER_SEC;
|
||||
}
|
||||
static void LoopMonitorWorker(void)
|
||||
{
|
||||
@ -150,7 +150,6 @@ namespace Hdc {
|
||||
exit = true;
|
||||
}
|
||||
for (auto [loop, stat] : g_loopStatusMap) {
|
||||
stat->ReportOnce(loop);
|
||||
stat->HungCheck(GetLoopHungTimeout());
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
void HungCheck(int64_t timeout) const;
|
||||
void UnUsedForUpdater(void) const {}
|
||||
public:
|
||||
void ReportOnce(uv_loop_t *loop);
|
||||
void StartReportTimer(void);
|
||||
static void ReportTimerProc(uv_timer_t *req);
|
||||
private:
|
||||
uv_loop_t *mLoop;
|
||||
|
@ -64,7 +64,9 @@ void HdcHostTCP::BroadcastFindDaemon(const char *broadcastLanIP)
|
||||
lstDaemonResult.clear();
|
||||
|
||||
uv_loop_t loopBroadcast;
|
||||
LoopStatus loopBroadcastStatus(&loopBroadcast, "loopBroadcast");
|
||||
uv_loop_init(&loopBroadcast);
|
||||
loopBroadcastStatus.StartReportTimer();
|
||||
struct sockaddr_in6 addr;
|
||||
uv_udp_send_t req;
|
||||
uv_udp_t client;
|
||||
|
@ -56,12 +56,12 @@ void HandleTest::TearDownTestCase() {}
|
||||
|
||||
void HandleTest::SetUp()
|
||||
{
|
||||
StartLoopMonitor();
|
||||
mCallDuration = 1 * MS_PER_SEC;
|
||||
uv_loop_init(&mLoop);
|
||||
mIdle.data = this;
|
||||
uv_idle_init(&mLoop, &mIdle);
|
||||
uv_idle_start(&mIdle, IdleCallBack);
|
||||
StartLoopMonitor();
|
||||
mLoopStatus = new LoopStatus(&mLoop, "HandleTestLoop");
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ HWTEST_F(HandleTest, Handle_NoHungTest_001, TestSize.Level0)
|
||||
HWTEST_F(HandleTest, Handle_HungTest_001, TestSize.Level0)
|
||||
{
|
||||
mCycles = 1;
|
||||
mCallDuration = 3 * MS_PER_SEC;
|
||||
mCallDuration = 6 * MS_PER_SEC;
|
||||
uv_run(&mLoop, UV_RUN_DEFAULT);
|
||||
ASSERT_EQ(0, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user