diff --git a/trunk/src/app/srs_app_recv_thread.cpp b/trunk/src/app/srs_app_recv_thread.cpp index 38101ba89..bc063da26 100644 --- a/trunk/src/app/srs_app_recv_thread.cpp +++ b/trunk/src/app/srs_app_recv_thread.cpp @@ -82,6 +82,9 @@ srs_error_t SrsRecvThread::start() srs_freep(trd); trd = new SrsSTCoroutine("recv", this, _parent_cid); + + //change stack size to 256K, fix crash when call some 3rd-part api. + ((SrsSTCoroutine*)trd)->set_stack_size(1 << 18); if ((err = trd->start()) != srs_success) { return srs_error_wrap(err, "recv thread"); diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index 71b6111d2..e1cc9ba74 100755 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -83,11 +83,15 @@ _ST_THREAD_CREATE_PFN _pfn_st_thread_create = (_ST_THREAD_CREATE_PFN)st_thread_c SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h) { + // TODO: FIXME: Reduce duplicated code. name = n; handler = h; trd = NULL; trd_err = srs_success; started = interrupted = disposed = cycle_done = false; + + // 0 use default, default is 64K. + stack_size = 0; } SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, SrsContextId cid) @@ -98,6 +102,9 @@ SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, SrsContextId c trd = NULL; trd_err = srs_success; started = interrupted = disposed = cycle_done = false; + + // 0 use default, default is 64K. + stack_size = 0; } SrsSTCoroutine::~SrsSTCoroutine() @@ -107,6 +114,11 @@ SrsSTCoroutine::~SrsSTCoroutine() srs_freep(trd_err); } +void SrsSTCoroutine::set_stack_size(int v) +{ + stack_size = v; +} + srs_error_t SrsSTCoroutine::start() { srs_error_t err = srs_success; @@ -124,8 +136,8 @@ srs_error_t SrsSTCoroutine::start() return err; } - - if ((trd = (srs_thread_t)_pfn_st_thread_create(pfn, this, 1, 0)) == NULL) { + + if ((trd = (srs_thread_t)_pfn_st_thread_create(pfn, this, 1, stack_size)) == NULL) { err = srs_error_new(ERROR_ST_CREATE_CYCLE_THREAD, "create failed"); srs_freep(trd_err); diff --git a/trunk/src/app/srs_app_st.hpp b/trunk/src/app/srs_app_st.hpp index 8931d1931..7191dfc36 100644 --- a/trunk/src/app/srs_app_st.hpp +++ b/trunk/src/app/srs_app_st.hpp @@ -119,6 +119,7 @@ class SrsSTCoroutine : public SrsCoroutine { private: std::string name; + int stack_size; ISrsCoroutineHandler* handler; private: srs_thread_t trd; @@ -136,6 +137,9 @@ public: SrsSTCoroutine(std::string n, ISrsCoroutineHandler* h); SrsSTCoroutine(std::string n, ISrsCoroutineHandler* h, SrsContextId cid); virtual ~SrsSTCoroutine(); +public: + // Set the stack size of coroutine, default to 0(64KB). + void set_stack_size(int v); public: // Start the thread. // @remark Should never start it when stopped or terminated.