From e2865c6ac173aac7eb80d7db8d0b055c7681a4cc Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 1 Sep 2016 16:51:09 +0800 Subject: [PATCH] workaround for #511, the fly stfd in close. 2.0.211 --- README.md | 2 ++ trunk/src/app/srs_app_rtmp_conn.cpp | 7 +++++-- trunk/src/app/srs_app_st.cpp | 10 +++------- trunk/src/app/srs_app_st.hpp | 1 + trunk/src/core/srs_core.hpp | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2428319c5..5350ead1c 100755 --- a/README.md +++ b/README.md @@ -340,6 +340,7 @@ Remark: ## History +* v2.0, 2016-09-01, workaround [bug #511] the fly stfd in close. 2.0.211 * v2.0, 2016-08-30, comment the pcr. * v2.0, 2016-08-18, fix [srs-librtmp#4](https://github.com/ossrs/srs-librtmp/issues/4) filter frame. * v2.0, 2016-08-10, fix socket timeout for librtmp. @@ -1231,6 +1232,7 @@ Winlin [bug #546]: https://github.com/ossrs/srs/issues/546 [bug #418]: https://github.com/ossrs/srs/issues/418 [bug #509]: https://github.com/ossrs/srs/issues/509 +[bug #511]: https://github.com/ossrs/srs/issues/511 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 5d788772c..0e26fb007 100755 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -225,8 +225,11 @@ int SrsRtmpConn::on_reload_vhost_removed(string vhost) // if the vhost connected is removed, disconnect the client. srs_trace("vhost %s removed/disabled, close client url=%s", vhost.c_str(), req->get_stream_url().c_str()); - - srs_close_stfd(stfd); + + // should never close the fd in another thread, + // one fd should managed by one thread, we should use interrupt instead. + // so we just ignore the vhost enabled event. + //srs_close_stfd(stfd); return ret; } diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index 7aecef697..ba818c9d6 100644 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -234,13 +234,9 @@ int srs_st_init() void srs_close_stfd(st_netfd_t& stfd) { if (stfd) { - int fd = st_netfd_fileno(stfd); - st_netfd_close(stfd); - stfd = NULL; - - // st does not close it sometimes, - // close it manually. - close(fd); + // we must ensure the close is ok. + int err = st_netfd_close(stfd); + srs_assert(err != -1); } } diff --git a/trunk/src/app/srs_app_st.hpp b/trunk/src/app/srs_app_st.hpp index 9516d3069..c49366eef 100644 --- a/trunk/src/app/srs_app_st.hpp +++ b/trunk/src/app/srs_app_st.hpp @@ -75,6 +75,7 @@ public: extern int srs_st_init(); // close the netfd, and close the underlayer fd. +// @remark when close, user must ensure io completed. extern void srs_close_stfd(st_netfd_t& stfd); #endif diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 5c4942174..be2c812a7 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 210 +#define VERSION_REVISION 211 // generated by configure, only macros. #include