2025-01-16 16:17:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file: $RCSfile: main.c,v $
|
|
|
|
|
|
* @brief: $IEC 61850 Protocol
|
|
|
|
|
|
*
|
|
|
|
|
|
* @version: $Revision: 1.9 $
|
|
|
|
|
|
* @date: $Date: 2020/10/28 05:21:18 $
|
|
|
|
|
|
* @author: $Author: lizhongming $
|
|
|
|
|
|
* @state: $State: Exp $
|
|
|
|
|
|
*
|
|
|
|
|
|
* @latest: $Id: main.c,v 1.9 2020/10/28 05:21:18 lizhongming Exp $
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "rdb_client.h"
|
|
|
|
|
|
#include "db_interface.h"
|
|
|
|
|
|
#include "node.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*lnk10-10 */
|
|
|
|
|
|
#include "../include/rocketmq/SimpleProducer.h"
|
2025-03-04 17:29:04 +08:00
|
|
|
|
|
|
|
|
|
|
#include "../cfg_parse/custom_printf.h"//lnk20250225
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
extern G_TEST_FLAG;
|
|
|
|
|
|
extern pthread_mutex_t mtx;
|
|
|
|
|
|
|
|
|
|
|
|
extern pt61850app_t *g_pt61850app;
|
|
|
|
|
|
extern node_t *g_node;
|
|
|
|
|
|
char g_my_conf_fname[256];
|
2025-04-29 15:05:36 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
apr_pool_t *g_root_pool;
|
|
|
|
|
|
apr_pool_t *g_rdb_pool;
|
|
|
|
|
|
apr_pool_t *g_cfg_pool;
|
|
|
|
|
|
uint16_t g_client_id = 0;
|
|
|
|
|
|
uint32_t g_node_id = 0;
|
|
|
|
|
|
uint32_t g_min_free_size = 1024;
|
|
|
|
|
|
int g_need_password = 0;
|
|
|
|
|
|
|
2025-03-04 17:29:04 +08:00
|
|
|
|
int INITFLAG = 0; //lnk20250304
|
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
char subdir[128] = "cfg_stat_data" ;
|
|
|
|
|
|
|
|
|
|
|
|
int usage();
|
|
|
|
|
|
int parse_param(int argc, const char **argv);
|
|
|
|
|
|
|
|
|
|
|
|
#include "ver_conf.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_SISCO
|
|
|
|
|
|
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
|
|
uint32_t g_dead_lock_counter = 0;
|
|
|
|
|
|
uint32_t g_thread_blocked_times = 0;
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
int three_secs_enabled = 0;
|
|
|
|
|
|
int auto_register_report_enabled = 0;
|
|
|
|
|
|
int g_front_seg_index = 0;
|
|
|
|
|
|
int g_front_seg_num = 0;
|
|
|
|
|
|
int FRONT_MP_NUM = 0;//<2F>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int g_front_num_count = 0;//<2F>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF>б<EFBFBD>ȫ<EFBFBD>ֹ<EFBFBD><D6B9>ܵ<EFBFBD>Ͷ<EFBFBD>ˣ<EFBFBD><CBA3>趨<EFBFBD>ĸ<EFBFBD><C4B8>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD>趨
|
|
|
|
|
|
void init_global_function_enable()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (strcmp(subdir,"cfg_stat_data")==0) { //<2F><>ʷ<EFBFBD><CAB7>̬
|
|
|
|
|
|
g_node_id = STAT_DATA_BASE_NODE_ID;
|
|
|
|
|
|
auto_register_report_enabled = 1;
|
|
|
|
|
|
}else if (strcmp(subdir,"cfg_3s_data")==0) { //ʵʱ
|
|
|
|
|
|
g_node_id = THREE_SECS_DATA_BASE_NODE_ID;
|
|
|
|
|
|
three_secs_enabled = 1;
|
|
|
|
|
|
}else if (strcmp(subdir,"cfg_soe_comtrade")==0) { //<2F>澯<EFBFBD><E6BEAF>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬
|
|
|
|
|
|
g_node_id = SOE_COMTRADE_BASE_NODE_ID;
|
|
|
|
|
|
}else if (strcmp(subdir,"cfg_his_data")==0) { //<2F><>ʹ<EFBFBD><CAB9>
|
|
|
|
|
|
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
|
|
|
|
|
|
g_node_id = HIS_DATA_BASE_NODE_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strcmp(subdir, "cfg_newhis_data") == 0) { //<2F><>ʹ<EFBFBD><CAB9>
|
|
|
|
|
|
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
|
|
|
|
|
|
g_node_id = NEW_HIS_DATA_BASE_NODE_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strcmp(subdir, "cfg_recallhis_data") == 0) { //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
g_node_id = RECALL_HIS_DATA_BASE_NODE_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (strcmp(subdir, "cfg_recallall_data") == 0) { //<2F><>ʹ<EFBFBD><CAB9>
|
|
|
|
|
|
g_node_id = RECALL_ALL_DATA_BASE_NODE_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _OS_UNIX_
|
|
|
|
|
|
void init_daemon(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
int pid;
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
if( pid = fork() )
|
|
|
|
|
|
exit(0); /** <20>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
else if( pid < 0 )
|
|
|
|
|
|
exit(1); /** forkʧ<6B>ܣ<EFBFBD><DCA3>˳<EFBFBD> */
|
|
|
|
|
|
|
|
|
|
|
|
/** <20>ǵ<EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD>̣<EFBFBD><CCA3><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4> */
|
|
|
|
|
|
|
|
|
|
|
|
setsid(); /** <20><>һ<EFBFBD>ӽ<EFBFBD><D3BD>̳<EFBFBD>Ϊ<EFBFBD>µĻỰ<C4BB>鳤<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD>鳤<EFBFBD><E9B3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն˷<D5B6><CBB7><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
|
|
if( pid = fork() )
|
|
|
|
|
|
exit(0); /** <20>ǵ<EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD> */
|
|
|
|
|
|
else if( pid < 0)
|
|
|
|
|
|
exit(1); /** forkʧ<6B>ܣ<EFBFBD><DCA3>˳<EFBFBD> */
|
|
|
|
|
|
|
|
|
|
|
|
chdir("/FeProject/bin/"); //multi process running at same time
|
|
|
|
|
|
umask(0); /** <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//"--subdir, set the subdir of /CloudForward/ as the working directory, \n"
|
|
|
|
|
|
int usage()
|
|
|
|
|
|
{
|
|
|
|
|
|
fprintf(stderr,"\nUsage : pt61850netd_pqfe -d [subdir] \n");
|
|
|
|
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int prepare_entironment_2()
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
|
|
|
|
|
|
/* apr library need call this first. */
|
|
|
|
|
|
apr_initialize(); //APACHE<48><45>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
atexit(apr_terminate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create node root pool */
|
|
|
|
|
|
rv = apr_pool_create(&g_root_pool, NULL); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
|
if(rv != APR_SUCCESS) {
|
|
|
|
|
|
fprintf(stderr,"%s","Create node root pool failed!\n");
|
|
|
|
|
|
return (-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SIGPIPE
|
|
|
|
|
|
/* Ignore writes to connections that have been closed at the other end. */
|
|
|
|
|
|
apr_signal(SIGPIPE, SIG_IGN);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
rv = create_log_handle(g_root_pool);
|
|
|
|
|
|
if(rv != APR_SUCCESS) {
|
|
|
|
|
|
printf("init_log failed!\n");
|
|
|
|
|
|
return (-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
unsigned int error = 0;
|
|
|
|
|
|
unsigned int warn = 0;
|
|
|
|
|
|
unsigned int info = 0;
|
|
|
|
|
|
log_config_t *log_handle = get_log_handle();
|
|
|
|
|
|
parse_log_switch_ini(&error,&warn,&info);
|
|
|
|
|
|
log_handle->status.debug = info;//0;//1;
|
|
|
|
|
|
log_handle->status.warn = warn;//0;//1;
|
|
|
|
|
|
log_handle->status.error = error;//0;//1;
|
|
|
|
|
|
}
|
|
|
|
|
|
echo_msg("==============================================================\n");
|
|
|
|
|
|
|
|
|
|
|
|
rv = apr_pool_create(&g_rdb_pool, g_root_pool); //<2F><><EFBFBD><EFBFBD>RDB<44>ڴ<EFBFBD>
|
|
|
|
|
|
if(rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Create system runtime pool failed!\n");
|
|
|
|
|
|
return (-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rv = apr_pool_create(&g_cfg_pool, g_root_pool); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
|
if(rv != APR_SUCCESS) {
|
|
|
|
|
|
echo_errg("Create system config pool failed!\n");
|
|
|
|
|
|
return (-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the register table. Call these functions first! */
|
|
|
|
|
|
echo_msg1("%-60s","Initialize system register......");
|
2025-04-29 15:05:36 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
echo_msg("OK\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
initTimezoneOffset();
|
|
|
|
|
|
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _OS_UNIX_
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
void printf_cur_user()
|
|
|
|
|
|
{
|
|
|
|
|
|
struct passwd *pwd;
|
|
|
|
|
|
pwd = getpwuid(getuid());
|
|
|
|
|
|
echo_warn1("Current user: %s\n", pwd->pw_name);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t stimer = 1;
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
|
|
|
|
|
|
/* Prepare the system context */
|
|
|
|
|
|
rv=prepare_entironment_2();
|
|
|
|
|
|
if (rv!=APR_SUCCESS){
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getVersion(argc,argv);
|
|
|
|
|
|
|
|
|
|
|
|
rv=parse_param(argc, argv);
|
|
|
|
|
|
if (rv!=APR_SUCCESS){
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _OS_UNIX_
|
|
|
|
|
|
#ifdef QT_NO_DEBUG
|
|
|
|
|
|
if (!g_need_password)
|
|
|
|
|
|
init_daemon();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
init_global_function_enable();
|
|
|
|
|
|
apr_snprintf(g_my_conf_fname,sizeof(g_my_conf_fname),"../%s/etc/pt61850netd_pqfe.xml",subdir);
|
|
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG_SISCO)
|
|
|
|
|
|
init_log_cfg ();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
#ifdef _OS_UNIX_
|
|
|
|
|
|
printf_cur_user();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (g_need_password) {
|
|
|
|
|
|
if ( process_login_verify() == 0) {
|
|
|
|
|
|
echo_warn("User login succeeded!\n");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
echo_warn("User login failed!\n");
|
|
|
|
|
|
apr_sleep(apr_time_from_sec(3));
|
|
|
|
|
|
exit(-59);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rv = init_rdb();
|
|
|
|
|
|
if (rv!=APR_SUCCESS){
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rv = run_protocol();
|
|
|
|
|
|
if (rv!=APR_SUCCESS){
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-04 17:29:04 +08:00
|
|
|
|
//<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;
|
|
|
|
|
|
}
|
2025-01-16 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
|
/* sleep 1s, just like 1s timer */
|
|
|
|
|
|
apr_sleep(apr_time_from_sec(1));
|
|
|
|
|
|
/* ÿ30<33><30><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>һ<EFBFBD><D2BB>״̬ */
|
|
|
|
|
|
|
|
|
|
|
|
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>
|
2025-03-04 17:29:04 +08:00
|
|
|
|
pthread_mutex_lock(&mtx);
|
2025-01-16 16:17:01 +08:00
|
|
|
|
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 ");
|
2025-02-10 17:03:15 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
apr_sleep(apr_time_from_sec(10));
|
|
|
|
|
|
exit(-1039);
|
|
|
|
|
|
}
|
2025-03-04 17:29:04 +08:00
|
|
|
|
pthread_mutex_unlock(&mtx);
|
2025-01-16 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo_warn1("%-60s","System shutdown now......");
|
|
|
|
|
|
apr_pool_destroy(g_root_pool);
|
|
|
|
|
|
echo_msg("OK\n");
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int parse_param(int argc, const char **argv)
|
|
|
|
|
|
{
|
|
|
|
|
|
apr_status_t rv;
|
|
|
|
|
|
apr_getopt_t *opt;
|
|
|
|
|
|
char *opt_arg;
|
|
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
|
|
|
|
char *p;
|
|
|
|
|
|
char temp[128];
|
2025-04-29 15:05:36 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
g_node_id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
echo_warn2("================= compiled@ %s %s =================\n",__DATE__ , __TIME__ );
|
|
|
|
|
|
|
|
|
|
|
|
/* Parse the command-line parameter */
|
|
|
|
|
|
if( argc > 1 ) {
|
|
|
|
|
|
rv = apr_getopt_init(&opt, g_root_pool, argc, argv);
|
|
|
|
|
|
|
|
|
|
|
|
while (apr_getopt(opt, "q:Q:a:A:d:D:p:P:f:F:r:R:T:t:s:S", &ch, &opt_arg) == APR_SUCCESS) {
|
|
|
|
|
|
switch (ch) {
|
|
|
|
|
|
case 'q':
|
|
|
|
|
|
case 'Q':
|
|
|
|
|
|
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
|
|
|
|
|
|
g_min_free_size = atoi(opt_arg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return (usage());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'R':
|
|
|
|
|
|
case 'r':
|
2025-04-29 15:05:36 +08:00
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case 's':
|
|
|
|
|
|
case 'S':
|
|
|
|
|
|
echo_warn1(">>>>>>>>>>>>>>>>>>>>>parse -s %s ", opt_arg);
|
|
|
|
|
|
strcpy(temp, opt_arg);
|
|
|
|
|
|
|
|
|
|
|
|
p = strtok(temp, "_"); //1_5
|
|
|
|
|
|
echo_warn1("p %s ", p);
|
|
|
|
|
|
g_front_seg_index = atoi(p);
|
|
|
|
|
|
|
|
|
|
|
|
printf("g_front_seg_index:%d",g_front_seg_index);
|
|
|
|
|
|
|
|
|
|
|
|
p = strtok(NULL, "_"); //1_5
|
|
|
|
|
|
echo_warn1("p %s ", p);
|
|
|
|
|
|
g_front_seg_num = atoi(p);
|
|
|
|
|
|
|
|
|
|
|
|
printf("g_front_seg_num:%d",g_front_seg_num);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'a':
|
|
|
|
|
|
case 'A':
|
|
|
|
|
|
strcpy(g_onlyIP,opt_arg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
case 'D':
|
|
|
|
|
|
strcpy(subdir,opt_arg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'T':
|
|
|
|
|
|
case 't':
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'f':
|
|
|
|
|
|
case 'F':
|
2025-04-29 15:05:36 +08:00
|
|
|
|
break;
|
2025-01-16 16:17:01 +08:00
|
|
|
|
case 'P':
|
|
|
|
|
|
case 'p':
|
|
|
|
|
|
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
|
|
|
|
|
|
g_need_password = atoi(opt_arg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return (usage());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case '?':
|
|
|
|
|
|
default:
|
|
|
|
|
|
return (usage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-04 17:29:04 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////<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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|