1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

add gperf to heap check, use reload signal to terminate program normally

This commit is contained in:
winlin 2014-03-06 18:12:19 +08:00
parent 03a14e2e1a
commit dcd568a0d7
6 changed files with 55 additions and 11 deletions

View file

@ -233,6 +233,14 @@ int SrsServer::cycle()
srs_update_system_time_ms();
if (signal_reload) {
// for gperf heap checker,
// @see: research/gperftools/heap-checker/heap_checker.cc
// if user interrupt the program, exit to check mem leak.
// but, if gperf, use reload to terminate the server,
// for the SIGINT will cause core-dump.
#ifdef SRS_GPERF
break;
#endif
signal_reload = false;
srs_info("get signal reload, to reload the config.");

View file

@ -37,6 +37,13 @@ SrsServer* _srs_server = new SrsServer();
#include <stdlib.h>
#include <signal.h>
#ifdef SRS_GPERF_HEAP_PROFILE
#include <gperftools/heap-profiler.h>
#endif
#ifdef SRS_GPERF_CPU_PROFILE
#include <gperftools/profiler.h>
#endif
void handler(int signo)
{
srs_trace("get a signal, signo=%d", signo);
@ -47,6 +54,17 @@ int main(int argc, char** argv)
{
int ret = ERROR_SUCCESS;
#ifdef SRS_GPERF_HEAP_CHECK
// env HEAPCHECK=normal ./objs/srs -c srs.conf
#endif
#ifdef SRS_GPERF_HEAP_PROFILE
HeapProfilerStart("gperf.srs");
#endif
#ifdef SRS_GPERF_CPU_PROFILE
ProfilerStart("gperf.srs.prof");
#endif
signal(SIGNAL_RELOAD, handler);
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {