Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: Add more utest for env config. v6.0.147 v7.0.4 #4142

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

suzp1984
Copy link
Contributor

@suzp1984 suzp1984 commented Aug 13, 2024

  1. don't use static variable to store the result;
  2. add more UT to handle the multi value and values with whitespaces;

related to #4092

#define SRS_OVERWRITE_BY_ENV_DIRECTIVE(key) { \
static SrsConfDirective* dir = NULL; \
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) { \
dir->args.push_back(vec[i]); \
} \
} \
if (dir) return dir; \
}

static SrsConfDirective* dir removed, this static var here is to avoid the memory leak, I add the SrsConfDirective instance to the env_dirs directive container, which will destroy itself inside SrsConfig destructor.

@suzp1984 suzp1984 marked this pull request as ready for review August 13, 2024 08:25
@suzp1984 suzp1984 marked this pull request as draft August 13, 2024 08:46
1. don't use static variable to store the result;
2. add more UT to handle the multi value and values with whitespaces;
@suzp1984 suzp1984 marked this pull request as ready for review August 13, 2024 10:09
@winlinvip winlinvip changed the title refine ENV config SRS_OVERWRITE_BY_ENV_DIRECTIVE Config: Add more utest for SRS_OVERWRITE_BY_ENV_DIRECTIVE Aug 14, 2024
@winlinvip winlinvip changed the title Config: Add more utest for SRS_OVERWRITE_BY_ENV_DIRECTIVE Config: Add more utest for env config Aug 14, 2024
@winlinvip winlinvip changed the title Config: Add more utest for env config Config: Add more utest for env config. v6.0.147 v7.0.4 Aug 15, 2024
@winlinvip winlinvip added the RefinedByAI Refined by AI/GPT. label Aug 15, 2024
@winlinvip winlinvip merged commit e323215 into ossrs:develop Aug 15, 2024
17 checks passed
winlinvip added a commit that referenced this pull request Aug 15, 2024
1. don't use static variable to store the result;
2. add more UT to handle the multi value and values with whitespaces;

related to #4092

https://github.com/ossrs/srs/blob/16e569d82357757ddac6ef91d7a5fe7837319909/trunk/src/app/srs_app_config.cpp#L71-L82

`static SrsConfDirective* dir` removed, this static var here is to avoid
the memory leak, I add the `SrsConfDirective` instance to the `env_dirs`
directive container, which will destroy itself inside `SrsConfig`
destructor.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RefinedByAI Refined by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants