OCT 1. 优化vCPE BRAS后线程linux系统文件描述符fd资源占用 340+->264
2. 删除多余硬件信息调试日志
This commit is contained in:
parent
cf5375c893
commit
789ddbc716
|
@ -27,7 +27,7 @@ void hardwareRefreshCb(uv_timer_t *UNUSED(pArg)) {
|
||||||
get_memory_info(&g_hardwareInfo.memInfo);
|
get_memory_info(&g_hardwareInfo.memInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\n", get_hardware_json());
|
//printf("%s\n", get_hardware_json());
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_hardware() {
|
int init_hardware() {
|
||||||
|
|
|
@ -14,11 +14,13 @@
|
||||||
#include "inet_misc.h"
|
#include "inet_misc.h"
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "msg_queue.h"
|
|
||||||
#include "http_svr.h"
|
#include "http_svr.h"
|
||||||
#include "lib_config.h"
|
#include "lib_config.h"
|
||||||
#include "prj_config.h"
|
#include "prj_config.h"
|
||||||
#include "zlog_module.h"
|
#include "zlog_module.h"
|
||||||
|
#ifdef ZEROMQ_ON
|
||||||
|
#include "msg_queue.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_CONFIG_FILE ("vcpe.cfg")
|
#define DEFAULT_CONFIG_FILE ("vcpe.cfg")
|
||||||
#define DEFAULT_CONFIG_DIR ("config")
|
#define DEFAULT_CONFIG_DIR ("config")
|
||||||
|
|
|
@ -25,6 +25,7 @@ using namespace std;
|
||||||
#include "sds/sds.h"
|
#include "sds/sds.h"
|
||||||
#include "inet_misc.h"
|
#include "inet_misc.h"
|
||||||
#include "http_svr.h"
|
#include "http_svr.h"
|
||||||
|
#include "task_manager.h"
|
||||||
|
|
||||||
extern data2 cfig;
|
extern data2 cfig;
|
||||||
extern bool kRunning;
|
extern bool kRunning;
|
||||||
|
@ -765,13 +766,36 @@ static void on_http_response_cb(void *pData,
|
||||||
free(pUserData);
|
free(pUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iptvCacheCb(void *UNUSED(pArg)) {
|
void iptvCacheCb(uv_timer_t *UNUSED(pArg)) {
|
||||||
do {
|
|
||||||
bool isReport = false;
|
bool isReport = false;
|
||||||
const char *pUrl = config_get_agent_iptv_report_url();
|
const char *pUrl = config_get_agent_iptv_report_url();
|
||||||
PIPTV_DEV_SET report = nullptr;
|
PIPTV_DEV_SET report = nullptr;
|
||||||
PIPTV_DEV_SET pDev, pTmp = nullptr;
|
PIPTV_DEV_SET pDev, pTmp = nullptr;
|
||||||
uv_rwlock_wrlock(&g_uvCacheLock);
|
uv_rwlock_wrlock(&g_uvCacheLock);
|
||||||
|
HASH_ITER(hh, g_iptvNewDevs, pDev, pTmp) uv_sleep(10);
|
||||||
|
HASH_ITER(hh, report, pDev, pTmp) {
|
||||||
|
HASH_DEL(report, pDev);
|
||||||
|
free(pDev);
|
||||||
|
}
|
||||||
|
HASH_ITER(hh, report, pDev, pTmp) if (isReport && pUrl && strlen(pUrl) > 0) {
|
||||||
|
cJSON *pRspMsg = cJSON_CreateObject();
|
||||||
|
cJSON *pMsgArray = cJSON_CreateArray();
|
||||||
|
cJSON_AddItemToObject(pRspMsg, "iptvDevs", pMsgArray);
|
||||||
|
|
||||||
|
HASH_ITER(hh, report, pDev, pTmp) {
|
||||||
|
cJSON *pRspItem = cJSON_CreateObject();
|
||||||
|
cJSON_AddStringToObject(pRspItem, "mac", pDev->iptvMAC);
|
||||||
|
cJSON_AddNumberToObject(pRspItem, "vni", pDev->vni);
|
||||||
|
pDev->isReport = 1;
|
||||||
|
cJSON_AddItemToArray(pMsgArray, pRspItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *pStrPro = proto_create_new(pRspMsg, 200);
|
||||||
|
|
||||||
|
// Report new IPTV device MAC
|
||||||
|
inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro);
|
||||||
|
}
|
||||||
|
uv_rwlock_wrunlock(&g_uvCacheLock);
|
||||||
HASH_ITER(hh, g_iptvNewDevs, pDev, pTmp) {
|
HASH_ITER(hh, g_iptvNewDevs, pDev, pTmp) {
|
||||||
PIPTV_DEV_SET pTemp;
|
PIPTV_DEV_SET pTemp;
|
||||||
const char *pDevMac = strdup(pDev->iptvMAC);
|
const char *pDevMac = strdup(pDev->iptvMAC);
|
||||||
|
@ -799,34 +823,6 @@ void iptvCacheCb(void *UNUSED(pArg)) {
|
||||||
free(pDev);
|
free(pDev);
|
||||||
free((void *)pDevMac);
|
free((void *)pDevMac);
|
||||||
}
|
}
|
||||||
uv_rwlock_wrunlock(&g_uvCacheLock);
|
|
||||||
|
|
||||||
if (isReport && pUrl && strlen(pUrl) > 0) {
|
|
||||||
cJSON *pRspMsg = cJSON_CreateObject();
|
|
||||||
cJSON *pMsgArray = cJSON_CreateArray();
|
|
||||||
cJSON_AddItemToObject(pRspMsg, "iptvDevs", pMsgArray);
|
|
||||||
|
|
||||||
HASH_ITER(hh, report, pDev, pTmp) {
|
|
||||||
cJSON *pRspItem = cJSON_CreateObject();
|
|
||||||
cJSON_AddStringToObject(pRspItem, "mac", pDev->iptvMAC);
|
|
||||||
cJSON_AddNumberToObject(pRspItem, "vni", pDev->vni);
|
|
||||||
pDev->isReport = 1;
|
|
||||||
cJSON_AddItemToArray(pMsgArray, pRspItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *pStrPro = proto_create_new(pRspMsg, 200);
|
|
||||||
|
|
||||||
// Report new IPTV device MAC
|
|
||||||
inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro);
|
|
||||||
}
|
|
||||||
|
|
||||||
HASH_ITER(hh, report, pDev, pTmp) {
|
|
||||||
HASH_DEL(report, pDev);
|
|
||||||
free(pDev);
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_sleep(10);
|
|
||||||
} while (true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -950,10 +946,13 @@ static HTTP_ROUTE_INFO g_routeTable[] = {
|
||||||
void opendhcp_init_http_server() {
|
void opendhcp_init_http_server() {
|
||||||
static int added = FALSE;
|
static int added = FALSE;
|
||||||
static uv_thread_t uvThread;
|
static uv_thread_t uvThread;
|
||||||
|
static uv_timer_t uvTm;
|
||||||
if (!added) {
|
if (!added) {
|
||||||
uv_rwlock_init(&g_uvCacheLock);
|
uv_rwlock_init(&g_uvCacheLock);
|
||||||
uv_thread_create(&uvThread, iptvCacheCb, nullptr);
|
uv_timer_init(get_task_manager(), &uvTm);
|
||||||
|
|
||||||
|
uv_timer_start(&uvTm, iptvCacheCb, 1000, 1000);
|
||||||
|
//uv_thread_create(&uvThread, iptvCacheCb, nullptr);
|
||||||
for (auto &i : g_routeTable) {
|
for (auto &i : g_routeTable) {
|
||||||
PHTTP_ROUTE_INFO p = &i;
|
PHTTP_ROUTE_INFO p = &i;
|
||||||
http_add_route(p->routeName, p->method, p->priority, p->cb, p->pUserData);
|
http_add_route(p->routeName, p->method, p->priority, p->cb, p->pUserData);
|
||||||
|
|
Loading…
Reference in New Issue