正在显示
6 个修改的文件
包含
88 行增加
和
24 行删除
| @@ -451,12 +451,21 @@ fi | @@ -451,12 +451,21 @@ fi | ||
| 451 | 451 | ||
| 452 | if [ $SRS_GPERF = YES ]; then | 452 | if [ $SRS_GPERF = YES ]; then |
| 453 | echo "#define SRS_GPERF" >> $SRS_AUTO_HEADERS_H | 453 | echo "#define SRS_GPERF" >> $SRS_AUTO_HEADERS_H |
| 454 | - #echo "#define SRS_GPERF_CPU_PROFILE" >> $SRS_AUTO_HEADERS_H | ||
| 455 | - #echo "#define SRS_GPERF_HEAP_PROFILE" >> $SRS_AUTO_HEADERS_H | ||
| 456 | - echo "#define SRS_GPERF_HEAP_CHECK" >> $SRS_AUTO_HEADERS_H | ||
| 457 | else | 454 | else |
| 458 | echo "#undef SRS_GPERF" >> $SRS_AUTO_HEADERS_H | 455 | echo "#undef SRS_GPERF" >> $SRS_AUTO_HEADERS_H |
| 459 | - echo "#undef SRS_GPERF_CPU_PROFILE" >> $SRS_AUTO_HEADERS_H | ||
| 460 | - echo "#undef SRS_GPERF_HEAP_PROFILE" >> $SRS_AUTO_HEADERS_H | ||
| 461 | - echo "#undef SRS_GPERF_HEAP_CHECK" >> $SRS_AUTO_HEADERS_H | 456 | +fi |
| 457 | +if [ $SRS_GPERF_MC = YES ]; then | ||
| 458 | + echo "#define SRS_GPERF_MC" >> $SRS_AUTO_HEADERS_H | ||
| 459 | +else | ||
| 460 | + echo "#undef SRS_GPERF_MC" >> $SRS_AUTO_HEADERS_H | ||
| 461 | +fi | ||
| 462 | +if [ $SRS_GPERF_MP = YES ]; then | ||
| 463 | + echo "#define SRS_GPERF_MP" >> $SRS_AUTO_HEADERS_H | ||
| 464 | +else | ||
| 465 | + echo "#undef SRS_GPERF_MP" >> $SRS_AUTO_HEADERS_H | ||
| 466 | +fi | ||
| 467 | +if [ $SRS_GPERF_CP = YES ]; then | ||
| 468 | + echo "#define SRS_GPERF_CP" >> $SRS_AUTO_HEADERS_H | ||
| 469 | +else | ||
| 470 | + echo "#undef SRS_GPERF_CP" >> $SRS_AUTO_HEADERS_H | ||
| 462 | fi | 471 | fi |
| @@ -18,6 +18,9 @@ SRS_HTTP=RESERVED | @@ -18,6 +18,9 @@ SRS_HTTP=RESERVED | ||
| 18 | SRS_RESEARCH=RESERVED | 18 | SRS_RESEARCH=RESERVED |
| 19 | SRS_UTEST=RESERVED | 19 | SRS_UTEST=RESERVED |
| 20 | SRS_GPERF=RESERVED | 20 | SRS_GPERF=RESERVED |
| 21 | +SRS_GPERF_MC=RESERVED | ||
| 22 | +SRS_GPERF_MP=RESERVED | ||
| 23 | +SRS_GPERF_CP=RESERVED | ||
| 21 | # arguments | 24 | # arguments |
| 22 | SRS_JOBS=1 | 25 | SRS_JOBS=1 |
| 23 | 26 | ||
| @@ -28,7 +31,9 @@ SRS_FFMPEG=YES | @@ -28,7 +31,9 @@ SRS_FFMPEG=YES | ||
| 28 | SRS_HTTP=YES | 31 | SRS_HTTP=YES |
| 29 | SRS_RESEARCH=NO | 32 | SRS_RESEARCH=NO |
| 30 | SRS_UTEST=YES | 33 | SRS_UTEST=YES |
| 31 | -SRS_GPERF=NO | 34 | +SRS_GPERF_MC=NO |
| 35 | +SRS_GPERF_MP=NO | ||
| 36 | +SRS_GPERF_CP=NO | ||
| 32 | 37 | ||
| 33 | ##################################################################################### | 38 | ##################################################################################### |
| 34 | # parse options | 39 | # parse options |
| @@ -56,7 +61,9 @@ do | @@ -56,7 +61,9 @@ do | ||
| 56 | --with-http) SRS_HTTP=YES ;; | 61 | --with-http) SRS_HTTP=YES ;; |
| 57 | --with-research) SRS_RESEARCH=YES ;; | 62 | --with-research) SRS_RESEARCH=YES ;; |
| 58 | --with-utest) SRS_UTEST=YES ;; | 63 | --with-utest) SRS_UTEST=YES ;; |
| 59 | - --with-gperf) SRS_GPERF=YES ;; | 64 | + --with-gmc) SRS_GPERF_MC=YES ;; |
| 65 | + --with-gmp) SRS_GPERF_MP=YES ;; | ||
| 66 | + --with-gcp) SRS_GPERF_CP=YES ;; | ||
| 60 | 67 | ||
| 61 | --without-ssl) SRS_SSL=NO ;; | 68 | --without-ssl) SRS_SSL=NO ;; |
| 62 | --without-hls) SRS_HLS=NO ;; | 69 | --without-hls) SRS_HLS=NO ;; |
| @@ -64,7 +71,9 @@ do | @@ -64,7 +71,9 @@ do | ||
| 64 | --without-http) SRS_HTTP=NO ;; | 71 | --without-http) SRS_HTTP=NO ;; |
| 65 | --without-research) SRS_RESEARCH=NO ;; | 72 | --without-research) SRS_RESEARCH=NO ;; |
| 66 | --without-utest) SRS_UTEST=NO ;; | 73 | --without-utest) SRS_UTEST=NO ;; |
| 67 | - --without-gperf) SRS_GPERF=NO ;; | 74 | + --without-gmc) SRS_GPERF_MC=NO ;; |
| 75 | + --without-gmp) SRS_GPERF_MP=NO ;; | ||
| 76 | + --without-gcp) SRS_GPERF_CP=NO ;; | ||
| 68 | 77 | ||
| 69 | --jobs) SRS_JOBS=${value} ;; | 78 | --jobs) SRS_JOBS=${value} ;; |
| 70 | 79 | ||
| @@ -101,7 +110,7 @@ if [ $help = yes ]; then | @@ -101,7 +110,7 @@ if [ $help = yes ]; then | ||
| 101 | --with-ffmpeg enable transcoding with ffmpeg. | 110 | --with-ffmpeg enable transcoding with ffmpeg. |
| 102 | --with-research build the research tools. | 111 | --with-research build the research tools. |
| 103 | --with-utest build the utest for srs. | 112 | --with-utest build the utest for srs. |
| 104 | - --with-gperf build srs with gperf tools. | 113 | + --with-gmc build memory check for srs with gperf tools. |
| 105 | 114 | ||
| 106 | --without-ssl disable rtmp complex handshake. | 115 | --without-ssl disable rtmp complex handshake. |
| 107 | --without-hls disable hls, rtmp streaming only. | 116 | --without-hls disable hls, rtmp streaming only. |
| @@ -109,7 +118,7 @@ if [ $help = yes ]; then | @@ -109,7 +118,7 @@ if [ $help = yes ]; then | ||
| 109 | --without-ffmpeg disable the ffmpeg transcoding feature. | 118 | --without-ffmpeg disable the ffmpeg transcoding feature. |
| 110 | --without-research do not build the research tools. | 119 | --without-research do not build the research tools. |
| 111 | --without-utest do not build the utest for srs. | 120 | --without-utest do not build the utest for srs. |
| 112 | - --without-gperf do not build srs with gperf tools. | 121 | + --without-gmc do not build memory check for srs with gperf tools. |
| 113 | 122 | ||
| 114 | --jobs[=N] Allow N jobs at once; infinite jobs with no arg. | 123 | --jobs[=N] Allow N jobs at once; infinite jobs with no arg. |
| 115 | used for make in the configure, for example, to make ffmpeg. | 124 | used for make in the configure, for example, to make ffmpeg. |
| @@ -146,10 +155,29 @@ if [ $SRS_UTEST = RESERVED ]; then | @@ -146,10 +155,29 @@ if [ $SRS_UTEST = RESERVED ]; then | ||
| 146 | echo "you must specifies the utest, see: ./configure --help"; | 155 | echo "you must specifies the utest, see: ./configure --help"; |
| 147 | __check_ok=NO | 156 | __check_ok=NO |
| 148 | fi | 157 | fi |
| 149 | -if [ $SRS_GPERF = RESERVED ]; then | ||
| 150 | - echo "you must specifies the gperf, see: ./configure --help"; | 158 | +if [ $SRS_GPERF_MC = RESERVED ]; then |
| 159 | + echo "you must specifies the gperf-mc, see: ./configure --help"; | ||
| 160 | + __check_ok=NO | ||
| 161 | +fi | ||
| 162 | +if [ $SRS_GPERF_MP = RESERVED ]; then | ||
| 163 | + echo "you must specifies the gperf-mp, see: ./configure --help"; | ||
| 164 | + __check_ok=NO | ||
| 165 | +fi | ||
| 166 | +if [ $SRS_GPERF_CP = RESERVED ]; then | ||
| 167 | + echo "you must specifies the gperf-cp, see: ./configure --help"; | ||
| 151 | __check_ok=NO | 168 | __check_ok=NO |
| 152 | fi | 169 | fi |
| 153 | if [ $__check_ok = NO ]; then | 170 | if [ $__check_ok = NO ]; then |
| 154 | exit 1; | 171 | exit 1; |
| 155 | fi | 172 | fi |
| 173 | + | ||
| 174 | +# generate the group option: SRS_GPERF | ||
| 175 | +if [ $SRS_GPERF_MC = YES ]; then | ||
| 176 | + SRS_GPERF=YES | ||
| 177 | +fi | ||
| 178 | +if [ $SRS_GPERF_MP = YES ]; then | ||
| 179 | + SRS_GPERF=YES | ||
| 180 | +fi | ||
| 181 | +if [ $SRS_GPERF_CP = YES ]; then | ||
| 182 | + SRS_GPERF=YES | ||
| 183 | +fi |
| @@ -64,6 +64,8 @@ SrsFfmpegSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_FFMPEG = YES ]; then Sr | @@ -64,6 +64,8 @@ SrsFfmpegSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_FFMPEG = YES ]; then Sr | ||
| 64 | SrsHttpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP = YES ]; then SrsHttpSummaryColor="\$(GREEN)"; fi | 64 | SrsHttpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP = YES ]; then SrsHttpSummaryColor="\$(GREEN)"; fi |
| 65 | SrsResearchSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\$(GREEN)"; fi | 65 | SrsResearchSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\$(GREEN)"; fi |
| 66 | SrsUtestSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\$(GREEN)"; fi | 66 | SrsUtestSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\$(GREEN)"; fi |
| 67 | +SrsGperfSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\$(GREEN)"; fi | ||
| 68 | +SrsGperfMCSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\$(GREEN)"; fi | ||
| 67 | 69 | ||
| 68 | ##################################################################################### | 70 | ##################################################################################### |
| 69 | # makefile | 71 | # makefile |
| @@ -91,6 +93,10 @@ default: bandwidth librtmp-sample utest | @@ -91,6 +93,10 @@ default: bandwidth librtmp-sample utest | ||
| 91 | @echo -e " \$(GREEN)librtmp-sample: ./research/librtmp, the srs-librtmp client sample\$(BLACK)" | 93 | @echo -e " \$(GREEN)librtmp-sample: ./research/librtmp, the srs-librtmp client sample\$(BLACK)" |
| 92 | @echo -e " ${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info.\$(BLACK)" | 94 | @echo -e " ${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info.\$(BLACK)" |
| 93 | @echo -e " ${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\$(BLACK)" | 95 | @echo -e " ${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\$(BLACK)" |
| 96 | + @echo -e " ${SrsGperfSummaryColor}gperf: gmc/gmp/gcp for srs, @see: \$(BLACK)" | ||
| 97 | + @echo -e " ${SrsGperfMCSummaryColor}gmc: gperf memory check, @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\$(BLACK)" | ||
| 98 | + @echo -e " ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/srs.conf # start gmc\$(BLACK)" | ||
| 99 | + @echo -e " ${SrsGperfMCSummaryColor}killall -2 srs # or CTRL+C to stop gmc\$(BLACK)" | ||
| 94 | @echo -e "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)" | 100 | @echo -e "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)" |
| 95 | 101 | ||
| 96 | help: | 102 | help: |
| @@ -313,10 +319,20 @@ if [ $SRS_UTEST = YES ]; then | @@ -313,10 +319,20 @@ if [ $SRS_UTEST = YES ]; then | ||
| 313 | else | 319 | else |
| 314 | echo -e "${YELLOW}note: utest for srs are not builded${BLACK}" | 320 | echo -e "${YELLOW}note: utest for srs are not builded${BLACK}" |
| 315 | fi | 321 | fi |
| 316 | -if [ $SRS_GPERF = YES ]; then | ||
| 317 | - echo -e "${GREEN}gperf(mem leak detect, mem/cpu perf) for srs are builded${BLACK}" | 322 | +if [ $SRS_GPERF_MC = YES ]; then |
| 323 | + echo -e "${GREEN}gmc(gperf memory check) for srs are builded${BLACK}" | ||
| 318 | else | 324 | else |
| 319 | - echo -e "${YELLOW}note: gperf(mem leak detect, mem/cpu perf) for srs are not builded${BLACK}" | 325 | + echo -e "${YELLOW}note: gmc(gperf memory check) for srs are not builded${BLACK}" |
| 326 | +fi | ||
| 327 | +if [ $SRS_GPERF_MP = YES ]; then | ||
| 328 | + echo -e "${GREEN}gmp(gperf memory profile) for srs are builded${BLACK}" | ||
| 329 | +else | ||
| 330 | + echo -e "${YELLOW}note: gmp(gperf memory profile) for srs are not builded${BLACK}" | ||
| 331 | +fi | ||
| 332 | +if [ $SRS_GPERF_CP = YES ]; then | ||
| 333 | + echo -e "${GREEN}gcp(gperf cpu profile) for srs are builded${BLACK}" | ||
| 334 | +else | ||
| 335 | + echo -e "${YELLOW}note: gcp(gperf cpu profile) for srs are not builded${BLACK}" | ||
| 320 | fi | 336 | fi |
| 321 | 337 | ||
| 322 | ##################################################################################### | 338 | ##################################################################################### |
| @@ -150,6 +150,7 @@ int SrsListener::cycle() | @@ -150,6 +150,7 @@ int SrsListener::cycle() | ||
| 150 | SrsServer::SrsServer() | 150 | SrsServer::SrsServer() |
| 151 | { | 151 | { |
| 152 | signal_reload = false; | 152 | signal_reload = false; |
| 153 | + signal_gmc_stop = false; | ||
| 153 | 154 | ||
| 154 | srs_assert(_srs_config); | 155 | srs_assert(_srs_config); |
| 155 | _srs_config->subscribe(this); | 156 | _srs_config->subscribe(this); |
| @@ -232,15 +233,18 @@ int SrsServer::cycle() | @@ -232,15 +233,18 @@ int SrsServer::cycle() | ||
| 232 | st_usleep(SRS_TIME_RESOLUTION_MS * 1000); | 233 | st_usleep(SRS_TIME_RESOLUTION_MS * 1000); |
| 233 | srs_update_system_time_ms(); | 234 | srs_update_system_time_ms(); |
| 234 | 235 | ||
| 235 | - if (signal_reload) { | ||
| 236 | // for gperf heap checker, | 236 | // for gperf heap checker, |
| 237 | // @see: research/gperftools/heap-checker/heap_checker.cc | 237 | // @see: research/gperftools/heap-checker/heap_checker.cc |
| 238 | // if user interrupt the program, exit to check mem leak. | 238 | // if user interrupt the program, exit to check mem leak. |
| 239 | -// but, if gperf, use reload to terminate the server, | ||
| 240 | -// for the SIGINT will cause core-dump. | ||
| 241 | -#ifdef SRS_GPERF | 239 | +// but, if gperf, use reload to ensure main return normally, |
| 240 | +// because directly exit will cause core-dump. | ||
| 241 | +#ifdef SRS_GPERF_MC | ||
| 242 | + if (signal_gmc_stop) { | ||
| 242 | break; | 243 | break; |
| 244 | + } | ||
| 243 | #endif | 245 | #endif |
| 246 | + | ||
| 247 | + if (signal_reload) { | ||
| 244 | signal_reload = false; | 248 | signal_reload = false; |
| 245 | srs_info("get signal reload, to reload the config."); | 249 | srs_info("get signal reload, to reload the config."); |
| 246 | 250 | ||
| @@ -274,8 +278,17 @@ void SrsServer::on_signal(int signo) | @@ -274,8 +278,17 @@ void SrsServer::on_signal(int signo) | ||
| 274 | { | 278 | { |
| 275 | if (signo == SIGNAL_RELOAD) { | 279 | if (signo == SIGNAL_RELOAD) { |
| 276 | signal_reload = true; | 280 | signal_reload = true; |
| 281 | + return; | ||
| 277 | } | 282 | } |
| 278 | 283 | ||
| 284 | +#ifdef SRS_GPERF_MC | ||
| 285 | + if (signo == SIGINT) { | ||
| 286 | + srs_trace("gmc is on, main cycle will terminate normally."); | ||
| 287 | + signal_gmc_stop = true; | ||
| 288 | + return; | ||
| 289 | + } | ||
| 290 | +#endif | ||
| 291 | + | ||
| 279 | // TODO: handle the SIGINT, SIGTERM. | 292 | // TODO: handle the SIGINT, SIGTERM. |
| 280 | } | 293 | } |
| 281 | 294 |
| @@ -73,6 +73,7 @@ private: | @@ -73,6 +73,7 @@ private: | ||
| 73 | std::vector<SrsConnection*> conns; | 73 | std::vector<SrsConnection*> conns; |
| 74 | std::vector<SrsListener*> listeners; | 74 | std::vector<SrsListener*> listeners; |
| 75 | bool signal_reload; | 75 | bool signal_reload; |
| 76 | + bool signal_gmc_stop; | ||
| 76 | public: | 77 | public: |
| 77 | SrsServer(); | 78 | SrsServer(); |
| 78 | virtual ~SrsServer(); | 79 | virtual ~SrsServer(); |
| @@ -54,10 +54,6 @@ int main(int argc, char** argv) | @@ -54,10 +54,6 @@ int main(int argc, char** argv) | ||
| 54 | { | 54 | { |
| 55 | int ret = ERROR_SUCCESS; | 55 | int ret = ERROR_SUCCESS; |
| 56 | 56 | ||
| 57 | -#ifdef SRS_GPERF_HEAP_CHECK | ||
| 58 | - // env HEAPCHECK=normal ./objs/srs -c srs.conf | ||
| 59 | -#endif | ||
| 60 | - | ||
| 61 | #ifdef SRS_GPERF_HEAP_PROFILE | 57 | #ifdef SRS_GPERF_HEAP_PROFILE |
| 62 | HeapProfilerStart("gperf.srs"); | 58 | HeapProfilerStart("gperf.srs"); |
| 63 | #endif | 59 | #endif |
| @@ -66,6 +62,7 @@ int main(int argc, char** argv) | @@ -66,6 +62,7 @@ int main(int argc, char** argv) | ||
| 66 | #endif | 62 | #endif |
| 67 | 63 | ||
| 68 | signal(SIGNAL_RELOAD, handler); | 64 | signal(SIGNAL_RELOAD, handler); |
| 65 | + signal(SIGINT, handler); | ||
| 69 | 66 | ||
| 70 | if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { | 67 | if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { |
| 71 | return ret; | 68 | return ret; |
-
请 注册 或 登录 后发表评论