OCT 1. 修正一处可能存在的内存异常问题

2. 增加服务上线,下线通知Agent进程消息
This commit is contained in:
huangxin 2023-01-30 10:43:20 +08:00
parent 1d1556fb07
commit 9fe48bc1ae
2 changed files with 42 additions and 10 deletions

View File

@ -1201,13 +1201,13 @@ int opendhcp_add_listener() {
return i; return i;
} }
void on_http_response_cb(void *pData, static void on_http_response_cb(void *pData,
unsigned int size, unsigned int size,
const char *pReqUrl, const char *pReqUrl,
const char *pDlPath, const char *pDlPath,
const char *pTaskUuid, const char *pTaskUuid,
int iFinished, int iFinished,
void *pUserData) { void *pUserData) {
if (iFinished == 0) { if (iFinished == 0) {
dzlog_debug("Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); dzlog_debug("Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size);
} else if (iFinished == 1) { } else if (iFinished == 1) {
@ -1215,6 +1215,8 @@ void on_http_response_cb(void *pData,
} else { } else {
dzlog_error("Download Error Code: %d\n", iFinished); dzlog_error("Download Error Code: %d\n", iFinished);
} }
free(pUserData);
} }
void iptvCacheCb(void *UNUSED(pArg)) { void iptvCacheCb(void *UNUSED(pArg)) {
@ -1262,9 +1264,7 @@ void iptvCacheCb(void *UNUSED(pArg)) {
const char *pStrPro = proto_create_new(pRspMsg, 200); const char *pStrPro = proto_create_new(pRspMsg, 200);
// Report new IPTV device MAC // Report new IPTV device MAC
inet_http_post_async(config_get_agent_iptv_report_url(), pStrPro, on_http_response_cb, nullptr); inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro);
free((void *)pStrPro);
} }
uv_sleep(10); uv_sleep(10);

View File

@ -19,6 +19,8 @@
#ifdef OPENDHCPD_ON #ifdef OPENDHCPD_ON
#include "proto.h" #include "proto.h"
#include "inet_misc.h"
#include "config.h"
#endif #endif
#ifdef OPENDHCPDDNS_ON #ifdef OPENDHCPDDNS_ON
@ -48,6 +50,31 @@ static void lwip_init_env() {
} }
#endif #endif
cJSON *create_app_process_status(int isStart) {
cJSON *pRspMsg = cJSON_CreateObject();
cJSON_AddNumberToObject(pRspMsg, "vni", cfg_get_user_vni_id());
cJSON_AddStringToObject(pRspMsg, "process", isStart ? "setup" : "exit");
return pRspMsg;
}
static void on_http_response_cb(void *pData,
unsigned int size,
const char *pReqUrl,
const char *pDlPath,
const char *pTaskUuid,
int iFinished,
void *pUserData) {
if (iFinished == 0) {
dzlog_debug("Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size);
} else if (iFinished == 1) {
dzlog_error("Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size);
} else {
dzlog_error("Download Error Code: %d\n", iFinished);
}
free(pUserData);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ret; int ret;
#ifdef OPENDHCPDDNS_ON #ifdef OPENDHCPDDNS_ON
@ -76,8 +103,13 @@ int main(int argc, char **argv) {
pppoe_session_init(); pppoe_session_init();
#endif #endif
const char *pStrSetup = proto_create_new(create_app_process_status(1), 200);
inet_http_post_async(config_get_agent_moniter_report_url(), pStrSetup, on_http_response_cb, (void *)pStrSetup);
task_manager_run(); task_manager_run();
const char *pStrExit = proto_create_new(create_app_process_status(0), 200);
inet_http_post_async(config_get_agent_moniter_report_url(), pStrSetup, on_http_response_cb, (void *)pStrSetup);
while (!is_system_cleanup()) { while (!is_system_cleanup()) {
sleep(1); sleep(1);
} }