-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
SmartPtr: Support load test for source by srs-bench. v6.0.130 #4097
Conversation
if (!enabled) { | ||
return 0; | ||
} | ||
return _srs_config->get_dash_dispose(req->vhost) * 1.1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dash_dispose
is not illustrated in full.conf
, which can be used as the doc. It's better to add it to full.conf
.
Another problem, the default dash_dispose
config is 0, or user can config the [hls | dash]_dispose
to 0 second, then this cleanup_delay
will be 0, is the cleanup_delay has to be keep > 0 ? In this case:
_srs_config->get_dash_dispose(req->vhost) > 0 ? _srs_config->get_dash_dispose(req->vhost) * 1.1 : 1
Let the cleanup_delay
at least 1 second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add dash_dispose to full.conf.
If user config dispose to 0, this cleanup_delay will return 0, which will be ignored.
It works as expectation. Won't fix.
# @remark apply for publisher timeout only, while "etc/init.d/srs stop" always dispose DASH. | ||
# Overwrite by env SRS_VHOST_DASH_DASH_DISPOSE for all vhosts. | ||
# default: 120 | ||
dash_dispose 120; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srs/trunk/src/app/srs_app_config.cpp
Lines 6862 to 6866 in e3d74fb
srs_utime_t SrsConfig::get_dash_dispose(std::string vhost) | |
{ | |
SRS_OVERWRITE_BY_ENV_SECONDS("srs.vhost.dash.dash_dispose"); // SRS_VHOST_DASH_DASH_DISPOSE | |
static srs_utime_t DEFAULT = 0; |
the default value in the code need to match the value here, be careful, change the default value in the srs_app_config
may has impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous default value is 0, but hls dispose defaults to 120. I think it's ok to change to the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice the dash_dispose default value in srs_app_config.cpp already changed to 120 to match the full.conf. No problem here.
} | ||
|
||
std::string vhost = pattern; | ||
if (pattern.at(0) != '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vhosts
store the vhost
-> ISrsHttpHandler
map, but the value, ISrsHttpHandler
never used, so is is ok to downgrade the map -> set
?
About the code to extract the vhost
, they are repeated in:
srs/trunk/src/protocol/srs_protocol_http_stack.cpp
Lines 706 to 712 in e3d74fb
std::string vhost = pattern; | |
if (pattern.at(0) != '/') { | |
if (pattern.find("/") != string::npos) { | |
vhost = pattern.substr(0, pattern.find("/")); | |
} | |
vhosts[vhost] = handler; | |
} |
Maybe a another method to get the vhost from pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need another PR to refine the code, because it not about the smart ptr.
Won't fix in this PR.
@@ -691,14 +691,12 @@ srs_error_t SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handle | |||
srs_assert(handler); | |||
|
|||
if (pattern.empty()) { | |||
srs_freep(handler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ISrsHttpHander
memory release still not perfect.
For a normal process, the ISrsHttpHandler
is created in:
srs/trunk/src/app/srs_app_http_stream.cpp
Line 991 in e3d74fb
entry->stream = new SrsLiveStream(r, entry->cache); |
and released in
srs/trunk/src/protocol/srs_protocol_http_stack.cpp
Lines 624 to 627 in e3d74fb
SrsHttpMuxEntry::~SrsHttpMuxEntry() | |
{ | |
srs_freep(handler); | |
} |
I would think if it's possible to manager it in same place, SrsLiveEntry
in this case. I see the auto release in SrsHttpStreamServer::http_unmount(SrsRequest* r)
, the ISrsHttpHander
, or SrsLiveStream
, seems freed twice in SrsHttpMuxEntry
destructor and SrsHttpStreamServer::http_unmount
And For exception cases, like here, handler
not freed here, but this exception not handled well, the handler
not released below at least.
srs/trunk/src/app/srs_app_http_stream.cpp
Lines 1008 to 1010 in e3d74fb
if ((err = mux.handle(mount, entry->stream)) != srs_success) { | |
return srs_error_wrap(err, "http: mount flv stream for vhost=%s failed", sid.c_str()); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, in http_unmount, won't free it twice, please check it carefully.
Second, if mux.handle failed, it won't free the stream, but the http_unmount will do.
So I think it's ok. Won't fix.
sflvs.erase(it); | ||
|
||
SrsLiveStream* stream = entry->stream; | ||
SrsAutoFree(SrsLiveStream, stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the SrsAutoFree
not good enough here, when stream
being released, stream = NULL
, but the entry->stream still hold an not NULL pointer, but it's memory already released.
So is it a good idea to let the SrsLiveEntry
destructor to free stream
, cache
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok, because the entry is removed and freed:
SrsLiveEntry* entry = it->second;
SrsAutoFree(SrsLiveEntry, entry);
streamHandlers.erase(it);
SrsLiveStream* stream = entry->stream;
SrsAutoFree(SrsLiveStream, stream);
SrsBufferCache* cache = entry->cache;
SrsAutoFree(SrsBufferCache, cache);
Won't fix.
253bfe6
to
a49f089
Compare
## Cause dash auto dispose is configured by seconds, but the code compare by usecond, 1 second = 1,000,000 useconds. releated to #4097 Bug introduced after #4097 supported Dash auto dispose after a timeout without media data. ## How to reproduce 1. `./objs/srs -c conf/dash.conf` 2. publish a rtmp stream. 3. play dash stream. -> no dash stream, always 404 error. --------- Co-authored-by: winlin <[email protected]>
Co-authored-by: Haibo Chen [email protected]
Co-authored-by: Jacob Su [email protected]