mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SquashSRS4: Refine the init of global objects
This commit is contained in:
parent
276bd2223e
commit
3256c7c2fa
20 changed files with 412 additions and 153 deletions
|
@ -70,10 +70,10 @@ srs_error_t run_hybrid_server();
|
|||
void show_macro_features();
|
||||
|
||||
// @global log and context.
|
||||
ISrsLog* _srs_log = new SrsFileLog();
|
||||
ISrsContext* _srs_context = new SrsThreadContext();
|
||||
ISrsLog* _srs_log = NULL;
|
||||
ISrsContext* _srs_context = NULL;
|
||||
// @global config object for app module.
|
||||
SrsConfig* _srs_config = new SrsConfig();
|
||||
SrsConfig* _srs_config = NULL;
|
||||
|
||||
// @global version of srs, which can grep keyword "XCORE"
|
||||
extern const char* _srs_version;
|
||||
|
@ -87,7 +87,15 @@ SrsServer* _srs_server = NULL;
|
|||
srs_error_t do_main(int argc, char** argv)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
||||
// Initialize global or thread-local variables.
|
||||
if ((err = srs_thread_initialize()) != srs_success) {
|
||||
return srs_error_wrap(err, "thread init");
|
||||
}
|
||||
|
||||
// For background context id.
|
||||
_srs_context->set_id(_srs_context->generate_id());
|
||||
|
||||
// TODO: support both little and big endian.
|
||||
srs_assert(srs_is_little_endian());
|
||||
|
||||
|
@ -215,10 +223,8 @@ srs_error_t do_main(int argc, char** argv)
|
|||
return err;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// For background context id.
|
||||
_srs_context->set_id(_srs_context->generate_id());
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
srs_error_t err = do_main(argc, argv);
|
||||
|
||||
if (err != srs_success) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue