diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 9b86c8c73..c3ac0a5fb 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -539,8 +539,6 @@ void SrsServer::destroy() } srs_freep(signal_manager); - - srs_freep(handler); } void SrsServer::dispose() diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 32646afa1..ac1e51414 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -293,10 +293,14 @@ private: virtual void dispose(); // server startup workflow, @see run_master() public: + /** + * initialize server with callback handler. + * @remark user must free the cycle handler. + */ virtual int initialize(ISrsServerCycle* cycle_handler); + virtual int initialize_st(); virtual int initialize_signal(); virtual int acquire_pid_file(); - virtual int initialize_st(); virtual int listen(); virtual int register_signal(); virtual int http_handle(); diff --git a/trunk/src/app/srs_app_thread.cpp b/trunk/src/app/srs_app_thread.cpp index dbc09ee0d..0007df3ea 100644 --- a/trunk/src/app/srs_app_thread.cpp +++ b/trunk/src/app/srs_app_thread.cpp @@ -129,19 +129,20 @@ namespace internal { if (ret) { srs_warn("core: ignore join thread failed."); } + } + + // wait the thread actually terminated. + // sometimes the thread join return -1, for example, + // when thread use st_recvfrom, the thread join return -1. + // so here, we use a variable to ensure the thread stopped. + // @remark even the thread not joinable, we must ensure the thread stopped when stop. + while (!really_terminated) { + st_usleep(10 * 1000); - // wait the thread actually terminated. - // sometimes the thread join return -1, for example, - // when thread use st_recvfrom, the thread join return -1. - // so here, we use a variable to ensure the thread stopped. - while (!really_terminated) { - st_usleep(10 * 1000); - - if (really_terminated) { - break; - } - srs_warn("core: wait thread to actually terminated"); + if (really_terminated) { + break; } + srs_warn("core: wait thread to actually terminated"); } tid = NULL;