1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Edge: Improve stability for state and fd closing. v5.0.214 v6.0.139 (#4126)

1. Should always stop coroutine before close fd, see #511, #1784
2. When edge forwarder coroutine quit, always set the error code.
3. Do not unpublish if invalid state.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
Winlin 2024-07-24 10:14:10 +08:00 committed by GitHub
parent 8c034e5a13
commit f04e9392fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 16 deletions

View file

@ -946,7 +946,8 @@ srs_error_t SrsRtmpConn::publishing(SrsSharedPtr<SrsLiveSource> source)
}
// TODO: FIXME: Should refine the state of publishing.
if ((err = acquire_publish(source)) == srs_success) {
srs_error_t acquire_err = acquire_publish(source);
if ((err = acquire_err) == srs_success) {
// use isolate thread to recv,
// @see: https://github.com/ossrs/srs/issues/237
SrsPublishRecvThread rtrd(rtmp, req, srs_netfd_fileno(stfd), 0, this, source, _srs_context->get_id());
@ -954,17 +955,13 @@ srs_error_t SrsRtmpConn::publishing(SrsSharedPtr<SrsLiveSource> source)
rtrd.stop();
}
// whatever the acquire publish, always release publish.
// when the acquire error in the midlle-way, the publish state changed,
// but failed, so we must cleanup it.
// @see https://github.com/ossrs/srs/issues/474
// @remark when stream is busy, should never release it.
if (srs_error_code(err) != ERROR_SYSTEM_STREAM_BUSY) {
// Release and callback when acquire publishing success, if not, we should ignore, because the source
// is not published by this session.
if (acquire_err == srs_success) {
release_publish(source);
http_hooks_on_unpublish();
}
http_hooks_on_unpublish();
return err;
}