正在显示
2 个修改的文件
包含
28 行增加
和
3 行删除
| @@ -629,6 +629,11 @@ SrsConfDirective::~SrsConfDirective() | @@ -629,6 +629,11 @@ SrsConfDirective::~SrsConfDirective() | ||
| 629 | 629 | ||
| 630 | SrsConfDirective* SrsConfDirective::copy() | 630 | SrsConfDirective* SrsConfDirective::copy() |
| 631 | { | 631 | { |
| 632 | + return copy(""); | ||
| 633 | +} | ||
| 634 | + | ||
| 635 | +SrsConfDirective* SrsConfDirective::copy(string except) | ||
| 636 | +{ | ||
| 632 | SrsConfDirective* cp = new SrsConfDirective(); | 637 | SrsConfDirective* cp = new SrsConfDirective(); |
| 633 | 638 | ||
| 634 | cp->conf_line = conf_line; | 639 | cp->conf_line = conf_line; |
| @@ -637,7 +642,10 @@ SrsConfDirective* SrsConfDirective::copy() | @@ -637,7 +642,10 @@ SrsConfDirective* SrsConfDirective::copy() | ||
| 637 | 642 | ||
| 638 | for (int i = 0; i < (int)directives.size(); i++) { | 643 | for (int i = 0; i < (int)directives.size(); i++) { |
| 639 | SrsConfDirective* directive = directives.at(i); | 644 | SrsConfDirective* directive = directives.at(i); |
| 640 | - cp->directives.push_back(directive->copy()); | 645 | + if (!except.empty() && directive->name == except) { |
| 646 | + continue; | ||
| 647 | + } | ||
| 648 | + cp->directives.push_back(directive->copy(except)); | ||
| 641 | } | 649 | } |
| 642 | 650 | ||
| 643 | return cp; | 651 | return cp; |
| @@ -1982,8 +1990,8 @@ int SrsConfig::persistence() | @@ -1982,8 +1990,8 @@ int SrsConfig::persistence() | ||
| 1982 | return ret; | 1990 | return ret; |
| 1983 | } | 1991 | } |
| 1984 | 1992 | ||
| 1985 | - // persistence root directive to writer. | ||
| 1986 | - if ((ret = root->persistence(&fw, 0)) != ERROR_SUCCESS) { | 1993 | + // do persistence to writer. |
| 1994 | + if ((ret = do_persistence(&fw)) != ERROR_SUCCESS) { | ||
| 1987 | ::unlink(path.c_str()); | 1995 | ::unlink(path.c_str()); |
| 1988 | return ret; | 1996 | return ret; |
| 1989 | } | 1997 | } |
| @@ -2000,6 +2008,18 @@ int SrsConfig::persistence() | @@ -2000,6 +2008,18 @@ int SrsConfig::persistence() | ||
| 2000 | return ret; | 2008 | return ret; |
| 2001 | } | 2009 | } |
| 2002 | 2010 | ||
| 2011 | +int SrsConfig::do_persistence(SrsFileWriter* fw) | ||
| 2012 | +{ | ||
| 2013 | + int ret = ERROR_SUCCESS; | ||
| 2014 | + | ||
| 2015 | + // persistence root directive to writer. | ||
| 2016 | + if ((ret = root->persistence(fw, 0)) != ERROR_SUCCESS) { | ||
| 2017 | + return ret; | ||
| 2018 | + } | ||
| 2019 | + | ||
| 2020 | + return ret; | ||
| 2021 | +} | ||
| 2022 | + | ||
| 2003 | int SrsConfig::minimal_to_json(SrsJsonObject* obj) | 2023 | int SrsConfig::minimal_to_json(SrsJsonObject* obj) |
| 2004 | { | 2024 | { |
| 2005 | int ret = ERROR_SUCCESS; | 2025 | int ret = ERROR_SUCCESS; |
| @@ -192,6 +192,8 @@ public: | @@ -192,6 +192,8 @@ public: | ||
| 192 | * so need to copy it to an old root directive, and use the copy result to do reload. | 192 | * so need to copy it to an old root directive, and use the copy result to do reload. |
| 193 | */ | 193 | */ |
| 194 | virtual SrsConfDirective* copy(); | 194 | virtual SrsConfDirective* copy(); |
| 195 | + // @param except the name of sub directive. | ||
| 196 | + virtual SrsConfDirective* copy(std::string except); | ||
| 195 | // args | 197 | // args |
| 196 | public: | 198 | public: |
| 197 | /** | 199 | /** |
| @@ -414,6 +416,9 @@ public: | @@ -414,6 +416,9 @@ public: | ||
| 414 | * persistence current config to file. | 416 | * persistence current config to file. |
| 415 | */ | 417 | */ |
| 416 | virtual int persistence(); | 418 | virtual int persistence(); |
| 419 | +private: | ||
| 420 | + virtual int do_persistence(SrsFileWriter* fw); | ||
| 421 | +public: | ||
| 417 | /** | 422 | /** |
| 418 | * dumps the global sections to json. | 423 | * dumps the global sections to json. |
| 419 | */ | 424 | */ |
-
请 注册 或 登录 后发表评论