From 4ab1d4ca4469ae778bbe6736243b4ea17496d1d2 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 18 Jan 2019 10:16:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ZLToolKit(=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=B8=A2=E5=A4=B1=E4=BA=8B=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZLToolKit | 2 +- tests/test_benchmark.cpp | 7 +++---- tests/test_httpApi.cpp | 6 ++++-- tests/test_httpClient.cpp | 7 ++++--- tests/test_player.cpp | 1 - tests/test_rtmpPusher.cpp | 6 +++--- tests/test_rtmpPusherMp4.cpp | 7 ++++--- tests/test_server.cpp | 5 +++-- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ZLToolKit b/ZLToolKit index 6d7e1bfa..2814157d 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit 6d7e1bfafa98837f16c0645d8ea89e51e3f68fea +Subproject commit 2814157d5998ea627a8a42d6e19ad5c4a2b767fc diff --git a/tests/test_benchmark.cpp b/tests/test_benchmark.cpp index 82c65647..b205e4d0 100644 --- a/tests/test_benchmark.cpp +++ b/tests/test_benchmark.cpp @@ -41,7 +41,8 @@ using namespace mediakit; int main(int argc, char *argv[]) { //设置退出信号处理函数 - signal(SIGINT, [](int) { EventPollerPool::Instance().shutdown(); }); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 //设置日志 Logger::Instance().add(std::make_shared()); @@ -52,7 +53,6 @@ int main(int argc, char *argv[]) { << "例如你想每隔50毫秒启动共计100个播放器(tcp方式播放rtsp://127.0.0.1/live/0 )可以输入以下命令:\r\n" << "./test_benchmark 100 50 rtsp://127.0.0.1/live/0 0\r\n" << endl; - Logger::Destory(); return 0; } @@ -81,8 +81,7 @@ int main(int argc, char *argv[]) { return true; }); - EventPollerPool::Instance().wait(); - AsyncTaskThread::Instance().CancelTask(0); + sem.wait(); return 0; } diff --git a/tests/test_httpApi.cpp b/tests/test_httpApi.cpp index b4887f42..44750ca1 100644 --- a/tests/test_httpApi.cpp +++ b/tests/test_httpApi.cpp @@ -102,7 +102,9 @@ static onceToken s_token([](){ int main(int argc,char *argv[]){ //设置退出信号处理函数 - signal(SIGINT, [](int){EventPollerPool::Instance().shutdown();}); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 + //设置日志 Logger::Instance().add(std::make_shared()); Logger::Instance().setWriter(std::make_shared()); @@ -133,7 +135,7 @@ int main(int argc,char *argv[]){ InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl; - EventPollerPool::Instance().wait(); + sem.wait(); return 0; } diff --git a/tests/test_httpClient.cpp b/tests/test_httpClient.cpp index 7acb9f68..381126d9 100644 --- a/tests/test_httpClient.cpp +++ b/tests/test_httpClient.cpp @@ -41,7 +41,9 @@ using namespace mediakit; int main(int argc, char *argv[]) { //设置退出信号处理函数 - signal(SIGINT, [](int) { EventPollerPool::Instance().shutdown(); }); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 + //设置日志 Logger::Instance().add(std::make_shared()); Logger::Instance().setWriter(std::make_shared()); @@ -182,8 +184,7 @@ int main(int argc, char *argv[]) { } }); - //事件轮询 - EventPollerPool::Instance().wait(); + sem.wait(); return 0; } diff --git a/tests/test_player.cpp b/tests/test_player.cpp index 7a9858c6..c2ba4109 100644 --- a/tests/test_player.cpp +++ b/tests/test_player.cpp @@ -50,7 +50,6 @@ int main(int argc, char *argv[]) { ErrorL << "\r\n测试方法:./test_player rtxp_url rtp_type\r\n" << "例如:./test_player rtsp://admin:123456@127.0.0.1/live/0 0\r\n" << endl; - Logger::Destory(); return 0; } diff --git a/tests/test_rtmpPusher.cpp b/tests/test_rtmpPusher.cpp index fa576419..2e6f1c87 100644 --- a/tests/test_rtmpPusher.cpp +++ b/tests/test_rtmpPusher.cpp @@ -83,7 +83,8 @@ void rePushDelay(const string &app, const string &stream, const string &url) { //这里才是真正执行main函数,你可以把函数名(domain)改成main,然后就可以输入自定义url了 int domain(const string &playUrl, const string &pushUrl) { //设置退出信号处理函数 - signal(SIGINT, [](int) { EventPollerPool::Instance().shutdown(); }); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 //设置日志 Logger::Instance().add(std::make_shared()); Logger::Instance().setWriter(std::make_shared()); @@ -101,8 +102,7 @@ int domain(const string &playUrl, const string &pushUrl) { createPusher(app, stream, pushUrl); } }); - //事件轮询 - EventPollerPool::Instance().wait(); + sem.wait(); return 0; } diff --git a/tests/test_rtmpPusherMp4.cpp b/tests/test_rtmpPusherMp4.cpp index e1d89c35..2f6e15ce 100644 --- a/tests/test_rtmpPusherMp4.cpp +++ b/tests/test_rtmpPusherMp4.cpp @@ -92,7 +92,9 @@ void rePushDelay(const string &app,const string &stream,const string &url){ //这里才是真正执行main函数,你可以把函数名(domain)改成main,然后就可以输入自定义url了 int domain(const string & filePath,const string & pushUrl){ //设置退出信号处理函数 - signal(SIGINT, [](int){EventPollerPool::Instance().shutdown();}); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 + //设置日志 Logger::Instance().add(std::make_shared()); Logger::Instance().setWriter(std::make_shared()); @@ -103,8 +105,7 @@ int domain(const string & filePath,const string & pushUrl){ //限制app为record是为了防止服务器上的文件被肆意访问 createPusher(appName,filePath,pushUrl); - //开始事件轮询 - EventPollerPool::Instance().wait(); + sem.wait(); return 0; } diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 89cc8d02..53abdd47 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -229,7 +229,8 @@ static onceToken s_token([](){ int main(int argc,char *argv[]) { //设置退出信号处理函数 - signal(SIGINT, [](int) { EventPollerPool::Instance().shutdown(); }); + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 signal(SIGHUP, [](int) { loadIniConfig(); }); //设置日志 @@ -354,7 +355,7 @@ int main(int argc,char *argv[]) { } }); - EventPollerPool::Instance().wait(); + sem.wait(); return 0; }