mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Fix the empty cid issue
This commit is contained in:
parent
7627c290c9
commit
89c0748234
2 changed files with 12 additions and 0 deletions
|
@ -212,6 +212,9 @@ srs_error_t do_main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
// For background context id.
|
||||||
|
_srs_context->generate_id();
|
||||||
|
|
||||||
srs_error_t err = do_main(argc, argv);
|
srs_error_t err = do_main(argc, argv);
|
||||||
|
|
||||||
if (err != srs_success) {
|
if (err != srs_success) {
|
||||||
|
|
|
@ -69,11 +69,20 @@ srs_error_t srs_st_init()
|
||||||
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
|
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
|
||||||
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
|
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Before ST init, we might have already inited the background cid.
|
||||||
|
string cid = _srs_context->get_id();
|
||||||
|
if (cid.empty()) {
|
||||||
|
cid = _srs_context->generate_id();
|
||||||
|
}
|
||||||
|
|
||||||
int r0 = 0;
|
int r0 = 0;
|
||||||
if((r0 = st_init()) != 0){
|
if((r0 = st_init()) != 0){
|
||||||
return srs_error_new(ERROR_ST_INITIALIZE, "st initialize failed, r0=%d", r0);
|
return srs_error_new(ERROR_ST_INITIALIZE, "st initialize failed, r0=%d", r0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch to the background cid.
|
||||||
|
_srs_context->set_id(cid);
|
||||||
srs_trace("st_init success, use %s", st_get_eventsys_name());
|
srs_trace("st_init success, use %s", st_get_eventsys_name());
|
||||||
|
|
||||||
return srs_success;
|
return srs_success;
|
||||||
|
|
Loading…
Reference in a new issue