mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Live: Crash for invalid live stream state when unmount HTTP. v6.0.146 v7.0.3 (#4141)
When unpublishing, the handler callback that will stop the coroutine: ```cpp _can_publish = true; handler->on_unpublish(req); ``` In this handler, the `http_unmount` will be called: ```cpp void SrsHttpStreamServer::http_unmount(SrsRequest* r) cache->stop(); ``` In this `http_unmount` function, there could be context switching. In such a situation, a new connection might publish the stream while the unpublish process is freeing the stream, leading to a crash. To prevent a new publisher, we should change the state only after all handlers and hooks are completed. --------- Co-authored-by: liumengte <liumengte@visionular.com> Co-authored-by: winlin <winlinvip@gmail.com>
This commit is contained in:
parent
16e569d823
commit
38417d9ccc
4 changed files with 7 additions and 4 deletions
|
@ -2632,8 +2632,7 @@ void SrsLiveSource::on_unpublish()
|
|||
meta->update_previous_ash();
|
||||
|
||||
srs_trace("cleanup when unpublish");
|
||||
|
||||
_can_publish = true;
|
||||
|
||||
if (!_source_id.empty()) {
|
||||
_pre_source_id = _source_id;
|
||||
}
|
||||
|
@ -2655,6 +2654,8 @@ void SrsLiveSource::on_unpublish()
|
|||
if (consumers.empty()) {
|
||||
stream_die_at_ = srs_get_system_time();
|
||||
}
|
||||
|
||||
_can_publish = true;
|
||||
}
|
||||
|
||||
srs_error_t SrsLiveSource::create_consumer(SrsLiveConsumer*& consumer)
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 6
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 145
|
||||
#define VERSION_REVISION 146
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 7
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 2
|
||||
#define VERSION_REVISION 3
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue