diff --git a/README.md b/README.md index bf63b7511..634c2ae03 100755 --- a/README.md +++ b/README.md @@ -208,6 +208,7 @@ Supported operating systems and hardware: * 2013-10-17, Created.
## History +* v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216. * v1.0, 2014-09-25, fix [#177](https://github.com/winlinvip/simple-rtmp-server/issues/177), dvr segment add config dvr_wait_keyframe. 0.9.213. * v1.0, 2014-08-28, fix [#167](https://github.com/winlinvip/simple-rtmp-server/issues/167), add openssl includes to utest. 0.9.209. * v1.0, 2014-08-27, max connections is 32756, for st use mmap default. 0.9.209 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 39cfd7a2d..fbb97b62a 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -50,16 +50,6 @@ using namespace _srs_internal; #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLog" -#define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR) - -int64_t FILE_SIZE(int fd) -{ - int64_t pre = FILE_OFFSET(fd); - int64_t pos = lseek(fd, 0, SEEK_END); - lseek(fd, pre, SEEK_SET); - return pos; -} - // '\n' #define __LF (char)0x0a @@ -407,12 +397,19 @@ int SrsConfig::reload() int ret = ERROR_SUCCESS; SrsConfig conf; + if ((ret = conf.parse_file(config_file.c_str())) != ERROR_SUCCESS) { srs_error("ignore config reloader parse file failed. ret=%d", ret); ret = ERROR_SUCCESS; return ret; } srs_info("config reloader parse file success."); + + if ((ret = conf.check_config()) != ERROR_SUCCESS) { + srs_error("ignore config reloader check config failed. ret=%d", ret); + ret = ERROR_SUCCESS; + return ret; + } return reload_conf(&conf); } @@ -1074,6 +1071,12 @@ int SrsConfig::parse_options(int argc, char** argv) ret = parse_file(config_file.c_str()); if (test_conf) { + // the parse_file never check the config, + // we check it when user requires check config file. + if (ret == ERROR_SUCCESS) { + ret = check_config(); + } + if (ret == ERROR_SUCCESS) { srs_trace("config file is ok"); exit(0); @@ -1082,6 +1085,25 @@ int SrsConfig::parse_options(int argc, char** argv) exit(ret); } } + + //////////////////////////////////////////////////////////////////////// + // check log name and level + //////////////////////////////////////////////////////////////////////// + if (true) { + std::string log_filename = this->get_log_file(); + if (get_log_tank_file() && log_filename.empty()) { + ret = ERROR_SYSTEM_CONFIG_INVALID; + srs_error("must specifies the file to write log to. ret=%d", ret); + return ret; + } + if (get_log_tank_file()) { + srs_trace("write log to file %s", log_filename.c_str()); + srs_trace("you can: tailf %s", log_filename.c_str()); + srs_trace("@see: %s", SRS_WIKI_URL_LOG); + } else { + srs_trace("write log to console"); + } + } return ret; } @@ -1189,6 +1211,8 @@ int SrsConfig::parse_file(const char* filename) int SrsConfig::check_config() { int ret = ERROR_SUCCESS; + + srs_trace("srs checking config..."); vector vhosts = get_vhosts(); @@ -1628,8 +1652,8 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer) if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { return ret; } - - return check_config(); + + return ret; } string SrsConfig::cwd() diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 90fc3f34d..675036e2f 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -340,6 +340,11 @@ private: * parse the config file, which is specified by cli. */ virtual int parse_file(const char* filename); +public: + /** + * check the parsed config. + */ + virtual int check_config(); protected: /** * parse config from the buffer. @@ -347,11 +352,6 @@ protected: * @remark, use protected for the utest to override with mock. */ virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); -private: - /** - * check the parsed config. - */ - virtual int check_config(); // global env public: /** diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index 296e140e5..da9be2f13 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -38,7 +38,7 @@ SrsStageInfo::SrsStageInfo(int _stage_id) { stage_id = _stage_id; nb_clients = 0; - age = printed_age = 0; + age = 0; update_print_time(); diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index ac76214eb..e29471fe5 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -40,7 +40,6 @@ public: int nb_clients; public: int64_t age; - int64_t printed_age; public: SrsStageInfo(int _stage_id); virtual ~SrsStageInfo(); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 8a308d916..d950532e9 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "215" +#define VERSION_REVISION "216" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index b9eca9447..1e82ed8ec 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -169,6 +169,11 @@ int main(int argc, char** argv) if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) { return ret; } + + // we check the config when the log initialized. + if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) { + return ret; + } srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION); srs_trace("license: "RTMP_SIG_SRS_LICENSE);