mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
解决程序退出时资源释放顺序问题
This commit is contained in:
parent
8311524935
commit
40c1d1cae6
@ -190,6 +190,10 @@ bool checkArgs(Args &&args,First &&first,KeyTypes && ...keys){
|
|||||||
throw InvalidArgs("缺少必要参数:" #__VA_ARGS__); \
|
throw InvalidArgs("缺少必要参数:" #__VA_ARGS__); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static unordered_map<uint64_t ,PlayerProxy::Ptr> s_proxyMap;
|
||||||
|
static recursive_mutex s_proxyMapMtx;
|
||||||
|
|
||||||
//安装api接口
|
//安装api接口
|
||||||
void installWebApi() {
|
void installWebApi() {
|
||||||
addHttpListener();
|
addHttpListener();
|
||||||
@ -342,8 +346,6 @@ void installWebApi() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
static unordered_map<uint64_t ,PlayerProxy::Ptr> s_proxyMap;
|
|
||||||
static recursive_mutex s_proxyMapMtx;
|
|
||||||
API_REGIST(api,addStreamProxy,{
|
API_REGIST(api,addStreamProxy,{
|
||||||
CHECK_ARGS("vhost","app","stream","url");
|
CHECK_ARGS("vhost","app","stream","url");
|
||||||
//添加拉流代理
|
//添加拉流代理
|
||||||
@ -424,6 +426,9 @@ void installWebApi() {
|
|||||||
val["msg"] = "success";
|
val["msg"] = "success";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void unInstallWebApi(){
|
||||||
|
lock_guard<recursive_mutex> lck(s_proxyMapMtx);
|
||||||
|
s_proxyMap.clear();
|
||||||
}
|
}
|
@ -328,5 +328,8 @@ void installWebHook(){
|
|||||||
});
|
});
|
||||||
#endif //ENABLE_MP4V2
|
#endif //ENABLE_MP4V2
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void unInstallWebHook(){
|
||||||
|
|
||||||
}
|
}
|
@ -153,7 +153,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
extern void installWebApi();
|
extern void installWebApi();
|
||||||
|
extern void unInstallWebApi();
|
||||||
extern void installWebHook();
|
extern void installWebHook();
|
||||||
|
extern void unInstallWebHook();
|
||||||
|
|
||||||
static void inline listen_shell_input(){
|
static void inline listen_shell_input(){
|
||||||
cout << "> 欢迎进入命令模式,你可以输入\"help\"命令获取帮助" << endl;
|
cout << "> 欢迎进入命令模式,你可以输入\"help\"命令获取帮助" << endl;
|
||||||
@ -278,11 +280,18 @@ int main(int argc,char *argv[]) {
|
|||||||
static semaphore sem;
|
static semaphore sem;
|
||||||
signal(SIGINT, [](int) {
|
signal(SIGINT, [](int) {
|
||||||
InfoL << "SIGINT:exit";
|
InfoL << "SIGINT:exit";
|
||||||
|
signal(SIGINT, SIG_IGN);// 设置退出信号
|
||||||
sem.post();
|
sem.post();
|
||||||
});// 设置退出信号
|
});// 设置退出信号
|
||||||
signal(SIGHUP, [](int) { mediakit::loadIniConfig(); });
|
signal(SIGHUP, [](int) { mediakit::loadIniConfig(); });
|
||||||
sem.wait();
|
sem.wait();
|
||||||
}
|
}
|
||||||
|
unInstallWebApi();
|
||||||
|
unInstallWebHook();
|
||||||
|
//休眠3秒再退出,防止资源释放顺序错误
|
||||||
|
InfoL << "程序退出中,请等待...";
|
||||||
|
sleep(3);
|
||||||
|
InfoL << "程序退出完毕!";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user