diff --git a/trunk/src/app/srs_app_conn.hpp b/trunk/src/app/srs_app_conn.hpp index db10ee423..ac95ca52d 100644 --- a/trunk/src/app/srs_app_conn.hpp +++ b/trunk/src/app/srs_app_conn.hpp @@ -47,8 +47,11 @@ public: virtual ~ISrsDisposingHandler(); public: // When before disposing resource, trigger when manager.remove(c), sync API. + // @remark Recommend to unref c, after this, no other objects refs to c. virtual void on_before_dispose(ISrsResource* c) = 0; // When disposing resource, async API, c is freed after it. + // @remark Recommend to stop any thread/timer of c, after this, fields of c is able + // to be deleted in any order. virtual void on_disposing(ISrsResource* c) = 0; }; diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index 5a1954a4b..9985f2b44 100755 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -207,13 +207,14 @@ srs_error_t SrsFastCoroutine::start() void SrsFastCoroutine::stop() { if (disposed) { + // TODO: FIXME: If previous stop is wait on st_thread_join, this call should assert fail. return; } disposed = true; interrupt(); - // When not started, the rd is NULL. + // When not started, the trd is NULL. if (trd) { void* res = NULL; int r0 = st_thread_join((st_thread_t)trd, &res); @@ -245,7 +246,9 @@ void SrsFastCoroutine::interrupt() if (trd_err == srs_success) { trd_err = srs_error_new(ERROR_THREAD_INTERRUPED, "interrupted"); } - + + // Note that if another thread is stopping thread and waiting in st_thread_join, + // the interrupt will make the st_thread_join fail. st_thread_interrupt((st_thread_t)trd); }