Skip to content

Commit

Permalink
Refine code.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 13, 2024
1 parent 26f6368 commit 953a62b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER;
#define SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_SECONDS)
#define SRS_OVERWRITE_BY_ENV_FLOAT_MILLISECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_MILLISECONDS)
#define SRS_OVERWRITE_BY_ENV_DIRECTIVE(key) { \
SrsConfDirective* dir = env_dirs->get(key); \
SrsConfDirective* dir = env_cache_->get(key); \
if (!dir && !srs_getenv(key).empty()) { \
std::vector<string> vec = srs_string_split(srs_getenv(key), " "); \
dir = new SrsConfDirective(); \
dir->name = key; \
for (size_t i = 0; i < vec.size(); ++i) { \
if (!vec[i].empty()) { \
dir->args.push_back(vec[i]); \
std::string value = vec[i]; \
if (!value.empty()) { \
dir->args.push_back(value); \
} \
} \
env_dirs->directives.push_back(dir); \
env_cache_->directives.push_back(dir); \
} \
if (dir) return dir; \
}
Expand Down Expand Up @@ -1349,14 +1350,14 @@ SrsConfig::SrsConfig()
root->conf_line = 0;
root->name = "root";

env_dirs = new SrsConfDirective();
env_dirs->name = "env";
env_cache_ = new SrsConfDirective();
env_cache_->name = "env_cache_";
}

SrsConfig::~SrsConfig()
{
srs_freep(root);
srs_freep(env_dirs);
srs_freep(env_cache_);
}

void SrsConfig::subscribe(ISrsReloadHandler* handler)
Expand Down
6 changes: 3 additions & 3 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ class SrsConfig
protected:
// The directive root.
SrsConfDirective* root;

// The Env directives.
SrsConfDirective* env_dirs;
private:
// The cache for parsing the config from environment variables.
SrsConfDirective* env_cache_;
// Reload section
private:
// The reload subscribers, when reload, callback all handlers.
Expand Down

0 comments on commit 953a62b

Please sign in to comment.