diff --git a/README.md b/README.md index dbc888f1f..4e80a8a84 100755 --- a/README.md +++ b/README.md @@ -162,6 +162,7 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-04-06, Merge [#1304][bug #1304], Fix ST coroutine pull error. 3.0.47 * v3.0, 2019-04-05, Merge [#1339][bug #1339], Support HTTP-FLV params. 3.0.46 * v3.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 3.0.44 * v3.0, 2018-08-26, SRS [console](https://github.com/ossrs/srs-ngb) support both [Chinese](http://ossrs.net:1985/console/ng_index.html) and [English](http://ossrs.net:1985/console/en_index.html). diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index d047c1f92..7e36e4a67 100755 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -101,8 +101,7 @@ srs_error_t SrsSTCoroutine::start() srs_error_t err = srs_success; if (started || disposed) { - err = srs_error_new(ERROR_THREAD_DISPOSED, - "failed for disposed=%d, started=%d", disposed, started); + err = srs_error_new(ERROR_THREAD_DISPOSED, "failed for disposed=%d, started=%d", disposed, started); if (trd_err == srs_success) { trd_err = srs_error_copy(err); @@ -139,9 +138,11 @@ void SrsSTCoroutine::stop() srs_assert(!r0); // Always override the error by the error from worker. - if ((srs_error_t)res != srs_success) { + srs_error_t err_res = (srs_error_t)res; + if (err_res != srs_success && trd_err != err_res) { srs_freep(trd_err); - trd_err = (srs_error_t)res; + // It's ok to directly use it, because it's returned by st_thread_join. + trd_err = err_res; return; } @@ -198,7 +199,17 @@ srs_error_t SrsSTCoroutine::cycle() void* SrsSTCoroutine::pfn(void* arg) { SrsSTCoroutine* p = (SrsSTCoroutine*)arg; - void* res = (void*)p->cycle(); - return res; + + srs_error_t err = p->cycle(); + + // Set the err for function pull to fetch it. + // @see https://github.com/ossrs/srs/pull/1304#issuecomment-480484151 + if (err != srs_success) { + srs_freep(p->trd_err); + // It's ok to directly use it, because it's returned by st_thread_join. + p->trd_err = err; + } + + return (void*)err; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index a4f7841a0..fb9c0b6f7 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // current release version #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 46 +#define VERSION_REVISION 47 // generated by configure, only macros. #include diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index f73fc4eaa..b68d15b51 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -2095,13 +2095,13 @@ VOID TEST(KernelUtility, AdtsUtils) } if (true) { - char data[] = {0xFF, 0x00}; + uint8_t data[] = {0xFF, 0x00}; SrsBuffer buf((char*)data, sizeof(data)); EXPECT_TRUE(!srs_aac_startswith_adts(&buf)); } if (true) { - char data[] = {0xFF, 0xF0}; + uint8_t data[] = {0xFF, 0xF0}; SrsBuffer buf((char*)data, sizeof(data)); EXPECT_TRUE(srs_aac_startswith_adts(&buf)); }