From 40c1d1cae6e7181d96f45f6a0c09905d8cbef580 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 20 May 2019 17:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=A8=8B=E5=BA=8F=E9=80=80?= =?UTF-8?q?=E5=87=BA=E6=97=B6=E8=B5=84=E6=BA=90=E9=87=8A=E6=94=BE=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 11 ++++++++--- server/WebHook.cpp | 3 +++ server/main.cpp | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 31df7ae2..34e88147 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -190,6 +190,10 @@ bool checkArgs(Args &&args,First &&first,KeyTypes && ...keys){ throw InvalidArgs("缺少必要参数:" #__VA_ARGS__); \ } + +static unordered_map s_proxyMap; +static recursive_mutex s_proxyMapMtx; + //安装api接口 void installWebApi() { addHttpListener(); @@ -342,8 +346,6 @@ void installWebApi() { }); - static unordered_map s_proxyMap; - static recursive_mutex s_proxyMapMtx; API_REGIST(api,addStreamProxy,{ CHECK_ARGS("vhost","app","stream","url"); //添加拉流代理 @@ -424,6 +426,9 @@ void installWebApi() { val["msg"] = "success"; }); +} - +void unInstallWebApi(){ + lock_guard lck(s_proxyMapMtx); + s_proxyMap.clear(); } \ No newline at end of file diff --git a/server/WebHook.cpp b/server/WebHook.cpp index f5102b71..674f0198 100644 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -328,5 +328,8 @@ void installWebHook(){ }); #endif //ENABLE_MP4V2 +} + +void unInstallWebHook(){ } \ No newline at end of file diff --git a/server/main.cpp b/server/main.cpp index 6b52e0dc..92e4e055 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -153,7 +153,9 @@ public: extern void installWebApi(); +extern void unInstallWebApi(); extern void installWebHook(); +extern void unInstallWebHook(); static void inline listen_shell_input(){ cout << "> 欢迎进入命令模式,你可以输入\"help\"命令获取帮助" << endl; @@ -278,11 +280,18 @@ int main(int argc,char *argv[]) { static semaphore sem; signal(SIGINT, [](int) { InfoL << "SIGINT:exit"; + signal(SIGINT, SIG_IGN);// 设置退出信号 sem.post(); });// 设置退出信号 signal(SIGHUP, [](int) { mediakit::loadIniConfig(); }); sem.wait(); } + unInstallWebApi(); + unInstallWebHook(); + //休眠3秒再退出,防止资源释放顺序错误 + InfoL << "程序退出中,请等待..."; + sleep(3); + InfoL << "程序退出完毕!"; return 0; }