mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
ST: Allow set the default stack size
This commit is contained in:
parent
a14f26971b
commit
97880f6bb7
3 changed files with 21 additions and 2 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue