fix bug in log upload

This commit is contained in:
lnk
2025-03-04 17:29:04 +08:00
parent 87f0a48ad7
commit 1df5385fc9
16 changed files with 434 additions and 80 deletions

View File

@@ -137,6 +137,7 @@
"stdbool.h": "c", "stdbool.h": "c",
"node.h": "c", "node.h": "c",
"save2json.h": "c", "save2json.h": "c",
"custom_printf.h": "c" "custom_printf.h": "c",
"suicacse.h": "c"
} }
} }

View File

@@ -203,6 +203,7 @@ const int MAX_CPUNO = 10;
//lnk20250121<32>ն<EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //lnk20250121<32>ն<EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int IED_COUNT = 300; //Ĭ<><C4AC>300 int IED_COUNT = 300; //Ĭ<><C4AC>300
extern int INITFLAG;
//WW 2-23-08-20 add start //WW 2-23-08-20 add start
otl_connect db; //OTL<54><4C><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD> WW 2023-08-20 otl_connect db; //OTL<54><4C><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD> WW 2023-08-20
@@ -11789,7 +11790,7 @@ void ledger(const char* terminal_id, QIODevice* outputDevice) {
if(ied != NULL){ if(ied != NULL){
ied_usr = (ied_usr_t*)ied->usr_ext; ied_usr = (ied_usr_t*)ied->usr_ext;
if (ied_usr != NULL && (terminal_id == NULL || strcmp(ied_usr->terminal_id, terminal_id) == 0)) { if (ied_usr != NULL && (terminal_id == NULL || strcmp(ied_usr->terminal_id, terminal_id) == 0)) {
printLedgerinshell(*ied_usr, outputDevice); // ʹ<><CAB9> QIODevice <20><><EFBFBD><EFBFBD> //printLedgerinshell(*ied_usr, outputDevice); // ʹ<><CAB9> QIODevice <20><><EFBFBD><EFBFBD>
//std::cout << "!!! print to log !!!"<< std::endl; //std::cout << "!!! print to log !!!"<< std::endl;
//printLedger(*ied_usr); //printLedger(*ied_usr);
found = true; found = true;
@@ -11829,6 +11830,9 @@ void value_print(const char *variableName, QTcpSocket *clientSocket) {
} else if (strcmp(variableName, "log") == 0) { } else if (strcmp(variableName, "log") == 0) {
sprintf(buffer, "showinshellflag = %d,debugOutputEnabled = %d,normalOutputEnabled = %d,warnOutputEnabled = %d,errorOutputEnabled = %d", showinshellflag,debugOutputEnabled,normalOutputEnabled,warnOutputEnabled,errorOutputEnabled); sprintf(buffer, "showinshellflag = %d,debugOutputEnabled = %d,normalOutputEnabled = %d,warnOutputEnabled = %d,errorOutputEnabled = %d", showinshellflag,debugOutputEnabled,normalOutputEnabled,warnOutputEnabled,errorOutputEnabled);
clientSocket->write(buffer); clientSocket->write(buffer);
}else if (strcmp(variableName, "init") == 0) {
sprintf(buffer, "INITFLAG = %d",INITFLAG);
clientSocket->write(buffer);
}else { }else {
clientSocket->write("Unknown variable name\n> "); clientSocket->write("Unknown variable name\n> ");
} }
@@ -15496,31 +15500,39 @@ void myQtMsgHandler(QtMsgType type, const char *msg)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD><CEA3><EFBFBD>д<EFBFBD><D0B4> debugList // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD><CEA3><EFBFBD>д<EFBFBD><D0B4> debugList
if (debugOutputEnabled) { if (debugOutputEnabled) {
pthread_mutex_lock(&debugListMutex); pthread_mutex_lock(&debugListMutex);
debugList.push_back(msg); // <20><> const char* ת<><D7AA>Ϊ std::string <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> debugList.push_back(msg);
pthread_mutex_unlock(&debugListMutex); pthread_mutex_unlock(&debugListMutex);
} }
// ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stderr<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD> // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FILE* output = nullptr;
const char* typeStr = ""; const char* typeStr = "";
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
typeStr = "Debug"; typeStr = "Debug";
output = stdout; // Debug <20>߱<EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD>
break; break;
case QtWarningMsg: case QtWarningMsg:
typeStr = "Warning"; typeStr = "Warning";
output = stderr; // Warning <20>߱<EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD>
break; break;
case QtCriticalMsg: case QtCriticalMsg:
typeStr = "Critical"; typeStr = "Critical";
output = stderr; // Critical <20>߱<EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD>
break; break;
case QtFatalMsg: case QtFatalMsg:
typeStr = "Fatal"; typeStr = "Fatal";
output = stderr; // Fatal <20>߱<EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD>
break; break;
} }
fprintf(stderr, "[%s] %s\n", typeStr, msg);
fflush(stderr);
if (type == QtFatalMsg) fprintf(output, "[%s] %s\n", typeStr, msg);
fflush(output);
// Fatal ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
if (type == QtFatalMsg) {
abort(); abort();
}
} }
// ------------------ <20>Զ<EFBFBD><D4B6><EFBFBD> printf <20><><EFBFBD><EFBFBD> ------------------ // ------------------ <20>Զ<EFBFBD><D4B6><EFBFBD> printf <20><><EFBFBD><EFBFBD> ------------------
@@ -15545,16 +15557,62 @@ int customPrintf(const char* format, ...)
return written; return written;
} }
// **ԭʼ `echo_msgX()` <20><>ʵ<EFBFBD><CAB5>** ///////////////////////////////////////////////////////////////////////////////
void real_echo_msg(const char *format, ...) { void echo_msg_errexy(const char *file_name, int line_no, int rv, const char *fmt, ...) {
char buffer[1024]; char __buf[1024];
va_list args; va_list __ap;
va_start(args, format); va_start(__ap, fmt);
vsnprintf(buffer, sizeof(buffer), format, args); vsnprintf(__buf, sizeof(__buf), fmt, __ap);
va_end(args); va_end(__ap);
printf("%s", buffer); // <20>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
fflush(stdout); // ? ȷ<><C8B7><EFBFBD><EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2> printf("[ERROR] rv=%d %s:%d => %s", rv, file_name, line_no, __buf);
fflush(stdout);
// д<><D0B4> errorList
if (errorOutputEnabled) {
pthread_mutex_lock(&errorListMutex);
errorList.push_back(std::string(__buf));
pthread_mutex_unlock(&errorListMutex);
}
}
void echo_msg_warnexy(const char *file_name, int line_no, const char *fmt, ...) {
char __buf[1024];
va_list __ap;
va_start(__ap, fmt);
vsnprintf(__buf, sizeof(__buf), fmt, __ap);
va_end(__ap);
// <20>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
printf("[WARN ] %s:%d => %s", file_name, line_no, __buf);
fflush(stdout);
// д<><D0B4> warnList
if (warnOutputEnabled) {
pthread_mutex_lock(&warnListMutex);
warnList.push_back(std::string(__buf));
pthread_mutex_unlock(&warnListMutex);
}
}
void echo_msg_debugexy(const char *file_name, int line_no, const char *fmt, ...) {
char __buf[1024];
va_list __ap;
va_start(__ap, fmt);
vsnprintf(__buf, sizeof(__buf), fmt, __ap);
va_end(__ap);
// <20>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
printf("[DEBUG] %s:%d => %s", file_name, line_no, __buf);
fflush(stdout);
// д<><D0B4> normalList
if (normalOutputEnabled) {
pthread_mutex_lock(&normalListMutex);
normalList.push_back(std::string(__buf));
pthread_mutex_unlock(&normalListMutex);
}
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@@ -36,45 +36,266 @@ extern pthread_mutex_t warnListMutex;
extern pthread_mutex_t normalListMutex; extern pthread_mutex_t normalListMutex;
extern pthread_mutex_t debugListMutex; extern pthread_mutex_t debugListMutex;
// **声明原始 echo_msgX(),让编译器知道它们存在**
void real_echo_msg(const char *format, ...);
// **拦截所有 `echo_msgX()`,让它同时存入 `normalList`**
#define echo_msgX(format, ...) \
do { \
char buffer[1024]; \
snprintf(buffer, sizeof(buffer), format, ##__VA_ARGS__); \
\
/* ✅ 先打印到 Shell确保不会卡死 */ \
printf("%s", buffer); \
fflush(stdout); /* ✅ 立即刷新,防止标准输出缓存 */ \
\
/* ✅ 先创建日志副本,避免锁住 `normalList` 过久 */ \
std::string logEntry(buffer); \
\
/* ✅ 仅在 `normalList` 操作时加锁,避免死锁 */ \
pthread_mutex_lock(&normalListMutex); \
normalList.push_back(logEntry); \
pthread_mutex_unlock(&normalListMutex); \
} while (0)
// **宏自动展开不同的 `echo_msg` 变体**
#define echo_msg1 echo_msgX
#define echo_msg2 echo_msgX
#define echo_msg3 echo_msgX
#define echo_msg4 echo_msgX
#define echo_msg5 echo_msgX
#define echo_msg6 echo_msgX
#define echo_msg7 echo_msgX
#define echo_msg8 echo_msgX
#define echo_msg9 echo_msgX
#define echo_msg10 echo_msgX
#define echo_msg11 echo_msgX
// **如果有更多的 `echo_msgX()`,继续定义**
extern "C" extern "C"
{ {
#endif #endif
void echo_msg_debugexy(const char *file_name, int line_no, const char *fmt, ...);
void echo_msg_warnexy(const char *file_name, int line_no, const char *fmt, ...);
void echo_msg_errexy(const char *file_name, int line_no, int rv, const char *fmt, ...);
#define echo_msg_debugexy(file_name, line_no, ...) \
echo_msg_debugexy(file_name, line_no, __VA_ARGS__)
#define echo_msg_warnexy(file_name, line_no, ...) \
echo_msg_warnexy(file_name, line_no, __VA_ARGS__)
#define echo_msg_errexy(file_name, line_no, rv, ...) \
echo_msg_errexy(file_name, line_no, rv, __VA_ARGS__)
// ======================= echo_warnX =======================
#ifdef echo_warn
#undef echo_warn
#endif
#define echo_warn(s) \
echo_msg_warnexy(__FILE__, __LINE__, ("%s"), s)
#ifdef echo_warn1
#undef echo_warn1
#endif
#define echo_warn1(fmt, s0) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0))
#ifdef echo_warn2
#undef echo_warn2
#endif
#define echo_warn2(fmt, s0, s1) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1))
#ifdef echo_warn3
#undef echo_warn3
#endif
#define echo_warn3(fmt, s0, s1, s2) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2))
#ifdef echo_warn4
#undef echo_warn4
#endif
#define echo_warn4(fmt, s0, s1, s2, s3) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3))
#ifdef echo_warn5
#undef echo_warn5
#endif
#define echo_warn5(fmt, s0, s1, s2, s3, s4) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4))
#ifdef echo_warn6
#undef echo_warn6
#endif
#define echo_warn6(fmt, s0, s1, s2, s3, s4, s5) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_warn7
#undef echo_warn7
#endif
#define echo_warn7(fmt, s0, s1, s2, s3, s4, s5, s6) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_warn8
#undef echo_warn8
#endif
#define echo_warn8(fmt, s0, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_warn9
#undef echo_warn9
#endif
#define echo_warn9(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_warn10
#undef echo_warn10
#endif
#define echo_warn10(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_warn11
#undef echo_warn11
#endif
#define echo_warn11(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_warn12
#undef echo_warn12
#endif
#define echo_warn12(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
// ======================= echo_errX =======================
#ifdef echo_err
#undef echo_err
#endif
#define echo_err(s, rv) \
echo_msg_errexy(__FILE__, __LINE__, (rv), ("%s"), (s))
#ifdef echo_errg
#undef echo_errg
#endif
#define echo_errg(s) \
echo_msg_errexy(__FILE__, __LINE__, (APR_EGENERAL), ("%s"), (s))
#ifdef echo_err1
#undef echo_err1
#endif
#define echo_err1(fmt, rv, s1) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1))
#ifdef echo_err2
#undef echo_err2
#endif
#define echo_err2(fmt, rv, s1, s2) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2))
#ifdef echo_err3
#undef echo_err3
#endif
#define echo_err3(fmt, rv, s1, s2, s3) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3))
#ifdef echo_err4
#undef echo_err4
#endif
#define echo_err4(fmt, rv, s1, s2, s3, s4) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4))
#ifdef echo_err5
#undef echo_err5
#endif
#define echo_err5(fmt, rv, s1, s2, s3, s4, s5) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_err6
#undef echo_err6
#endif
#define echo_err6(fmt, rv, s1, s2, s3, s4, s5, s6) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_err7
#undef echo_err7
#endif
#define echo_err7(fmt, rv, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_err8
#undef echo_err8
#endif
#define echo_err8(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_err9
#undef echo_err9
#endif
#define echo_err9(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_err10
#undef echo_err10
#endif
#define echo_err10(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_err11
#undef echo_err11
#endif
#define echo_err11(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
#ifdef echo_err12
#undef echo_err12
#endif
#define echo_err12(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11), (s12))
// ======================= echo_msgX =======================
#ifdef echo_msg
#undef echo_msg
#endif
#define echo_msg(s) \
echo_msg_debugexy(__FILE__, __LINE__, ("%s"), (s))
#ifdef echo_msg1
#undef echo_msg1
#endif
#define echo_msg1(fmt, s1) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1))
#ifdef echo_msg2
#undef echo_msg2
#endif
#define echo_msg2(fmt, s1, s2) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2))
#ifdef echo_msg3
#undef echo_msg3
#endif
#define echo_msg3(fmt, s1, s2, s3) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3))
#ifdef echo_msg4
#undef echo_msg4
#endif
#define echo_msg4(fmt, s1, s2, s3, s4) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4))
#ifdef echo_msg5
#undef echo_msg5
#endif
#define echo_msg5(fmt, s1, s2, s3, s4, s5) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_msg6
#undef echo_msg6
#endif
#define echo_msg6(fmt, s1, s2, s3, s4, s5, s6) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_msg7
#undef echo_msg7
#endif
#define echo_msg7(fmt, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_msg8
#undef echo_msg8
#endif
#define echo_msg8(fmt, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_msg9
#undef echo_msg9
#endif
#define echo_msg9(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_msg10
#undef echo_msg10
#endif
#define echo_msg10(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_msg11
#undef echo_msg11
#endif
#define echo_msg11(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
#ifdef echo_msg12
#undef echo_msg12
#endif
#define echo_msg12(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11), (s12))
// 自定义的 printf 函数 // 自定义的 printf 函数
int customPrintf(const char* format, ...); int customPrintf(const char* format, ...);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -68,6 +68,8 @@ extern "C" {
#define nullptr NULL #define nullptr NULL
#endif #endif
extern int INITFLAG;
extern QMutex kafka_data_list_mutex; extern QMutex kafka_data_list_mutex;
extern QList<Ckafka_data_t> kafka_data_list; extern QList<Ckafka_data_t> kafka_data_list;
@@ -1888,6 +1890,8 @@ int find_mp_index_from_mp_id(std::string line)
int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg) int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
{ {
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) { if (msg == NULL) {
std::cerr << "Received null message." << std::endl; std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER; return E_RECONSUME_LATER;
@@ -1947,6 +1951,8 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg) int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
{ {
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) { if (msg == NULL) {
std::cerr << "Received null message." << std::endl; std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER; return E_RECONSUME_LATER;
@@ -1982,6 +1988,7 @@ int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg) int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
{ {
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) { if (msg == NULL) {
std::cerr << "Received null message." << std::endl; std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER; return E_RECONSUME_LATER;
@@ -2016,6 +2023,7 @@ int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg) int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg)
{ {
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) { if (msg == NULL) {
std::cerr << "Received null message." << std::endl; std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER; return E_RECONSUME_LATER;
@@ -2050,6 +2058,7 @@ int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg) int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
{ {
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>
std::cout << "myMessageCallbackrecall"<< std::endl; std::cout << "myMessageCallbackrecall"<< std::endl;

View File

@@ -110,6 +110,16 @@ protected:
//lnk20250106 //lnk20250106
extern bool showinshellflag; extern bool showinshellflag;
#ifdef __cplusplus
extern "C" {
#endif
void doMonitorTaskmain(void);
#ifdef __cplusplus
}
#endif
class Worker : public QObject class Worker : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -162,6 +172,11 @@ public slots:
connect(timer, SIGNAL(timeout()), this, SLOT(doPeriodicTask())); connect(timer, SIGNAL(timeout()), this, SLOT(doPeriodicTask()));
timer->start(60000); // ÿ60<36><EFBFBD><EBB4A5>һ<EFBFBD><D2BB> timer->start(60000); // ÿ60<36><EFBFBD><EBB4A5>һ<EFBFBD><D2BB>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6BBBB><EFBFBD>̵߳ļ<CCB5><C4BC><EFBFBD>
QTimer *monitorTimer = new QTimer(this);
connect(monitorTimer, SIGNAL(timeout()), this, SLOT(doMonitorTask()));
monitorTimer->start(1000); // ÿ1<C3BF><EFBFBD><EBB4A5>һ<EFBFBD><D2BB>
std::cout << "Timer started, event loop running in thread: " << QThread::currentThreadId() << std::endl; std::cout << "Timer started, event loop running in thread: " << QThread::currentThreadId() << std::endl;
qDebug() << "Timer started, event loop running in thread:" << QThread::currentThreadId(); qDebug() << "Timer started, event loop running in thread:" << QThread::currentThreadId();
} }
@@ -202,6 +217,10 @@ private slots:
} }
} }
void doMonitorTask() {
doMonitorTaskmain();
}
void onNewConnection() { void onNewConnection() {
if (!server) return; if (!server) return;
@@ -336,7 +355,7 @@ private:
helpText += "log - Execute rocketmq_test_log\n"; helpText += "log - Execute rocketmq_test_log\n";
helpText += "ledger <id> - Execute ledger with optional terminal_id\n"; helpText += "ledger <id> - Execute ledger with optional terminal_id\n";
helpText += "viewlog <level> - View logs (ERROR, WARN, NORMAL, DEBUG)\n"; helpText += "viewlog <level> - View logs (ERROR, WARN, NORMAL, DEBUG)\n";
helpText += "value <valuename> - Execute value print with valuename : iedcount frontfun frontindex remtable log\n"; helpText += "value <valuename> - Execute value print with valuename : iedcount frontfun frontindex remtable log init\n";
helpText += "exit - Exit the shell\n"; helpText += "exit - Exit the shell\n";
helpText += "help - Show this help message\n"; helpText += "help - Show this help message\n";
clientSocket->write(helpText.toUtf8()); clientSocket->write(helpText.toUtf8());

View File

@@ -51,7 +51,7 @@ using namespace std;
SM4 sm4Encode; SM4 sm4Encode;
sm4Encode.sm4_enc((char*)input,seriseLen+4,(char*)output,szKey); sm4Encode.sm4_enc((char*)input,seriseLen+4,(char*)output,szKey);
printf("%lld || %s || %x %x %x %x\n", now_secs, output, pTime[3], pTime[2], pTime[1], pTime[0]); printf("now_secs:%lld ||series: %s ||ptime: %x %x %x %x\n", now_secs, output, pTime[3], pTime[2], pTime[1], pTime[0]);//lnk20250304
} }
void MyGetSM4Code(char* input,unsigned char* szKey,char* output) void MyGetSM4Code(char* input,unsigned char* szKey,char* output)

View File

@@ -17,7 +17,6 @@
#include "apr_time.h" #include "apr_time.h"
#include <stdbool.h>//lnk20241022 #include <stdbool.h>//lnk20241022
#include "../cfg_parse/custom_printf.h"//lnk20250225
#define LOG_IDX (0) #define LOG_IDX (0)
#define RPT_IDX (1) #define RPT_IDX (1)

View File

@@ -17,6 +17,9 @@
/*lnk10-10 */ /*lnk10-10 */
#include "../include/rocketmq/SimpleProducer.h" #include "../include/rocketmq/SimpleProducer.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
extern G_TEST_FLAG; extern G_TEST_FLAG;
extern pthread_mutex_t mtx; extern pthread_mutex_t mtx;
@@ -35,6 +38,8 @@ uint32_t g_node_id = 0;
uint32_t g_min_free_size = 1024; uint32_t g_min_free_size = 1024;
int g_need_password = 0; int g_need_password = 0;
int INITFLAG = 0; //lnk20250304
char subdir[128] = "cfg_stat_data" ; char subdir[128] = "cfg_stat_data" ;
int usage(); int usage();
@@ -276,26 +281,34 @@ int main(int argc, const char **argv)
} }
//lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> //lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
//OTLConnect(); //OTLConnect();
rv = run_protocol(); rv = run_protocol();
if (rv!=APR_SUCCESS){ if (rv!=APR_SUCCESS){
return rv; return rv;
} }
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>־,<2C><>ֹ<EFBFBD><D6B9>δ׼<CEB4><D7BC><EFBFBD><EFBFBD>ȫ<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><C2B1><EFBFBD>
INITFLAG = 1;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("INITFLAG=%d\n",INITFLAG);
if (1 == G_TEST_FLAG) {
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ֻ<EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
printf("try_start_mqtest_thread \n");
int ret = try_start_mqtest_thread(0,NULL);
// <20>ȴ<EFBFBD><C8B4>߳<EFBFBD><DFB3>˳<EFBFBD>
echo_warn1("%-60s","System shutdown now......");
apr_pool_destroy(g_root_pool);
echo_msg("OK\n");
return ret;
}
while(1) { while(1) {
/* sleep 1s, just like 1s timer */ /* sleep 1s, just like 1s timer */
apr_sleep(apr_time_from_sec(1)); apr_sleep(apr_time_from_sec(1));
/* ÿ30<33><30><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>һ<EFBFBD><D2BB>״̬ */ /* ÿ30<33><30><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>һ<EFBFBD><D2BB>״̬ */
/*<2A><><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD>lnk10-10 */
//rocketmq_test_rt();
//rocketmq_test_ud();
//rocketmq_test_rc();
/*lnk20241029recall<6C>ӿڲ<D3BF><DAB2><EFBFBD>*/
//curltest();
/*202411-1lnk<6E><6B><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */ /*202411-1lnk<6E><6B><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */
//SOEFileWeb_test(); //SOEFileWeb_test();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
@@ -327,14 +340,14 @@ int main(int argc, const char **argv)
} }
//lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD> //lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD>
pthread_mutex_lock(&mtx); printf("main thread hold lock !!!!!!!!!!!"); pthread_mutex_lock(&mtx);
if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD> if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD>
MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart "); MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart ");
apr_sleep(apr_time_from_sec(10)); apr_sleep(apr_time_from_sec(10));
exit(-1039); exit(-1039);
} }
pthread_mutex_unlock(&mtx); printf("main thread free lock !!!!!!!!!!!"); pthread_mutex_unlock(&mtx);
} }
@@ -455,3 +468,41 @@ int parse_param(int argc, const char **argv)
} }
///////////////////////////////////////////////////////////////<2F><><EFBFBD>Ӳ<EFBFBD><D3B2>Խ<EFBFBD><D4BD>̵ļ<CCB5><C4BC>غ<EFBFBD><D8BA><EFBFBD>lnk20250304
void doMonitorTaskmain(void) {
static int stimer = 0;
stimer++;
if( !(stimer++ % 60) ) {//<2F><><EFBFBD><EFBFBD>
if (g_dead_lock_counter++ >=3) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_thread_blocked_times++;
g_dead_lock_counter = 0;
}
MVL_LOG_ACSE1 ("MYLOG: current g_thread_blocked_times = %u ", g_thread_blocked_times);
if (FRONT_MP_NUM <= 1) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_front_num_count++;
}
else {
g_front_num_count = 0;
}
}
//work<72>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>3*13<31><33><EFBFBD>ӣ<EFBFBD><D3A3>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
if (g_thread_blocked_times>=13) {
MVL_LOG_ACSE0 ("MYLOG: g_thread_blocked_times>=3, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
//lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD>
pthread_mutex_lock(&mtx);
if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD>
MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
pthread_mutex_unlock(&mtx);
}

View File

@@ -21,6 +21,7 @@
#include "ied.h" #include "ied.h"
#include "../json/mms_json_inter.h" #include "../json/mms_json_inter.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
void clear_rpt_counter_by_trigger(trigger_t *trigger); void clear_rpt_counter_by_trigger(trigger_t *trigger);

View File

@@ -38,6 +38,7 @@
#include "tp4.h" #include "tp4.h"
#include "db_interface.h" #include "db_interface.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
/************************************************************************/ /************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */ /* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */ /* __FILE__ strings. */

View File

@@ -56,6 +56,7 @@
#include "rdb_client.h" #include "rdb_client.h"
#include "db_interface.h" #include "db_interface.h"
#include "../json/mms_json_inter.h" #include "../json/mms_json_inter.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
/************************************************************************/ /************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */ /* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */ /* __FILE__ strings. */

View File

@@ -79,7 +79,7 @@
#include "../mms/db_interface.h" #include "../mms/db_interface.h"
#include <ctype.h> //lnk20241119 #include <ctype.h> //lnk20241119
#include "../cfg_parse/custom_printf.h"//lnk20250225
extern uint32_t g_node_id; extern uint32_t g_node_id;
extern char subdir[128]; extern char subdir[128];
unsigned int g_no_auth = 0; unsigned int g_no_auth = 0;
@@ -1176,8 +1176,7 @@ S_SEC_ENCRYPT_CTRL *encryptCtrl = NULL; /* conn enctryption info */
//lnk20241119<31><39><EFBFBD><EFBFBD><EFBFBD>жϺʹ<CFBA>ӡ<EFBFBD><D3A1>ȷ<EFBFBD><C8B7>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԿΪ<D4BF><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD> //lnk20241119<31><39><EFBFBD><EFBFBD><EFBFBD>жϺʹ<CFBA>ӡ<EFBFBD><D3A1>ȷ<EFBFBD><C8B7>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԿΪ<D4BF><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>
if (!is_empty_or_whitespace(dev_series) || !is_empty_or_whitespace(dev_key)) { if (!is_empty_or_whitespace(dev_series) || !is_empty_or_whitespace(dev_key)) {
printf("dev_series= %s\n", dev_series); printf("dev_series= %s,dev_key= %s\n", dev_series,dev_key);
printf("dev_key= %s\n", dev_key);
/* Fill out an authentication structure */ /* Fill out an authentication structure */
authInfo = &authInfoStr; authInfo = &authInfoStr;
authInfo->auth_pres = SD_TRUE; authInfo->auth_pres = SD_TRUE;

View File

@@ -195,7 +195,7 @@
#include "mvl_log.h" #include "mvl_log.h"
#include "mloguser.h" #include "mloguser.h"
#include "mmsop_en.h" #include "mmsop_en.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
#if defined(MAP30_ACSE) #if defined(MAP30_ACSE)
#include "suicacse.h" #include "suicacse.h"

View File

@@ -12,7 +12,7 @@
#include <string.h> #include <string.h>
#include "rdb_client.h" #include "rdb_client.h"
#include "xmltools.h" #include "xmltools.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
//int comtrade_remain_file_num = 2147483647; //int comtrade_remain_file_num = 2147483647;
int comtrade_remain_file_num = 0; int comtrade_remain_file_num = 0;

View File

@@ -24,6 +24,7 @@ extern int g_front_seg_index;
extern int g_front_seg_num; extern int g_front_seg_num;
#include "../include/rocketmq/SimpleProducer.h" #include "../include/rocketmq/SimpleProducer.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
//////////////////////////////////////////// ////////////////////////////////////////////
#ifdef DEBUG_SISCO #ifdef DEBUG_SISCO
SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__; SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__;
@@ -289,7 +290,7 @@ apr_status_t run_protocol()
{ {
printf("g_onlyIP[0] != 0!\n\a"); printf("g_onlyIP[0] != 0!\n\a");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>socket<65><74>http<74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>socket<65><74>http<74>߳<EFBFBD>
} }
else //socket<65><74>http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳Ŀ<CCB5><C4BF><EFBFBD> else //socket<65><74>http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳Ŀ<CCB5><C4BF><EFBFBD>
@@ -362,11 +363,7 @@ apr_status_t run_protocol()
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>/////////////////////////////////////////////////////////////////////////////////////////////////// //lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////////
} }
if (1 == G_TEST_FLAG) {
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("try_start_mqtest_thread \n");
try_start_mqtest_thread(0,NULL);
}
} }
//lnkɾ<6B><C9BE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD> //lnkɾ<6B><C9BE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD>
@@ -382,10 +379,6 @@ apr_status_t run_protocol()
printf("try_start_ontimer_thread \n"); printf("try_start_ontimer_thread \n");
try_start_ontimer_thread(); try_start_ontimer_thread();
//OTLTestSelect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
///////////////////WW end
return APR_SUCCESS; return APR_SUCCESS;
} }

View File

@@ -13,6 +13,7 @@
#include "rdb_client.h" #include "rdb_client.h"
#include "xmltools.h" #include "xmltools.h"
#include "db_interface.h" #include "db_interface.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
//extern rdb_t* g_rdb ; //extern rdb_t* g_rdb ;
extern node_t* g_node ; extern node_t* g_node ;
extern char g_my_conf_fname[256]; extern char g_my_conf_fname[256];