Skip to content

Commit 510567e

Browse files
committed
修复驴头不对马嘴的bug
1 parent 503037c commit 510567e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

server/src/main.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void CMain::OnDelClient(int ClientNetID)
119119
}
120120
m_OfflineAlarmThreadData.pClients = m_aClients;
121121
m_OfflineAlarmThreadData.pWatchDogs = m_aCWatchDogs;
122+
m_OfflineAlarmThreadData.m_ReloadRequired = ClientID;
122123
thread_create(offlineAlarmThread, &m_OfflineAlarmThreadData);
123124
}
124125

@@ -504,8 +505,9 @@ void CMain::offlineAlarmThread(void *pUser)
504505
CJSONUpdateThreadData *m_OfflineAlarmThreadData = (CJSONUpdateThreadData *)pUser;
505506
CClient *pClients = m_OfflineAlarmThreadData->pClients;
506507
CWatchDog *pWatchDogs = m_OfflineAlarmThreadData->pWatchDogs;
508+
volatile short ClientID = m_OfflineAlarmThreadData->m_ReloadRequired;
507509
thread_sleep(6000);
508-
if(!pClients->m_Connected)
510+
if(!pClients[ClientID].m_Connected)
509511
{
510512
int ID = 0;
511513
while (strcmp(pWatchDogs[ID].m_aName, "NULL"))
@@ -514,13 +516,13 @@ void CMain::offlineAlarmThread(void *pUser)
514516
typedef exprtk::expression<double> expression_t;
515517
typedef exprtk::parser<double> parser_t;
516518
const std::string expression_string = pWatchDogs[ID].m_aRule;
517-
std::string username = pClients->m_aUsername;
518-
std::string name = pClients->m_aName;
519-
std::string type = pClients->m_aType;
520-
std::string host = pClients->m_aHost;
521-
std::string location = pClients->m_aLocation;
522-
std::double_t online4 = pClients->m_Stats.m_Online4;
523-
std::double_t online6 = pClients->m_Stats.m_Online6;
519+
std::string username = pClients[ClientID].m_aUsername;
520+
std::string name = pClients[ClientID].m_aName;
521+
std::string type = pClients[ClientID].m_aType;
522+
std::string host = pClients[ClientID].m_aHost;
523+
std::string location = pClients[ClientID].m_aLocation;
524+
std::double_t online4 = pClients[ClientID].m_Stats.m_Online4;
525+
std::double_t online6 = pClients[ClientID].m_Stats.m_Online6;
524526

525527
symbol_table_t symbol_table;
526528
symbol_table.add_stringvar("username", username);
@@ -541,10 +543,10 @@ void CMain::offlineAlarmThread(void *pUser)
541543
if (expression.value() > 0)
542544
{
543545
time_t currentStamp = (long long)time(/*ago*/0);
544-
if ((currentStamp-pClients->m_AlarmLastTime) > pWatchDogs[ID].m_aInterval)
546+
if ((currentStamp-pClients[ClientID].m_AlarmLastTime) > pWatchDogs[ID].m_aInterval)
545547
{
546548
printf("客户端下线且超过阈值, Client disconnects and sends alert information\n");
547-
pClients->m_AlarmLastTime = currentStamp;
549+
pClients[ClientID].m_AlarmLastTime = currentStamp;
548550
CURL *curl;
549551
CURLcode res;
550552
curl_global_init(CURL_GLOBAL_ALL);
@@ -560,11 +562,11 @@ void CMain::offlineAlarmThread(void *pUser)
560562
sprintf(encodeBuffer, "【告警名称】 %s \n\n【告警时间】 %s \n\n【用户名】 %s \n\n【节点名】 %s \n\n【虚拟化】 %s \n\n【主机名】 %s \n\n【位 置】 %s",
561563
pWatchDogs[ID].m_aName,
562564
standardTime,
563-
pClients->m_aUsername,
564-
pClients->m_aName,
565-
pClients->m_aType,
566-
pClients->m_aHost,
567-
pClients->m_aLocation);
565+
pClients[ClientID].m_aUsername,
566+
pClients[ClientID].m_aName,
567+
pClients[ClientID].m_aType,
568+
pClients[ClientID].m_aHost,
569+
pClients[ClientID].m_aLocation);
568570
char *encodeUrl = curl_easy_escape(curl, encodeBuffer, strlen(encodeBuffer));
569571

570572
//standard url

0 commit comments

Comments
 (0)