mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
ST: Print log when multiple thread stop one coroutine. (#1708)
This commit is contained in:
parent
ff33940d90
commit
93964bb037
2 changed files with 14 additions and 0 deletions
|
@ -125,6 +125,7 @@ SrsFastCoroutine::SrsFastCoroutine(string n, ISrsCoroutineHandler* h)
|
|||
trd = NULL;
|
||||
trd_err = srs_success;
|
||||
started = interrupted = disposed = cycle_done = false;
|
||||
stopping_ = false;
|
||||
|
||||
// 0 use default, default is 64K.
|
||||
stack_size = 0;
|
||||
|
@ -138,6 +139,7 @@ SrsFastCoroutine::SrsFastCoroutine(string n, ISrsCoroutineHandler* h, SrsContext
|
|||
trd = NULL;
|
||||
trd_err = srs_success;
|
||||
started = interrupted = disposed = cycle_done = false;
|
||||
stopping_ = false;
|
||||
|
||||
// 0 use default, default is 64K.
|
||||
stack_size = 0;
|
||||
|
@ -192,9 +194,14 @@ srs_error_t SrsFastCoroutine::start()
|
|||
void SrsFastCoroutine::stop()
|
||||
{
|
||||
if (disposed) {
|
||||
if (stopping_) {
|
||||
srs_error("thread is stopping by %s", stopping_cid_.c_str());
|
||||
srs_assert(!stopping_);
|
||||
}
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
stopping_ = true;
|
||||
|
||||
interrupt();
|
||||
|
||||
|
@ -226,6 +233,9 @@ void SrsFastCoroutine::stop()
|
|||
trd_err = srs_error_new(ERROR_THREAD_TERMINATED, "terminated");
|
||||
}
|
||||
|
||||
// Now, we'are stopped.
|
||||
stopping_ = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,10 @@ private:
|
|||
bool disposed;
|
||||
// Cycle done, no need to interrupt it.
|
||||
bool cycle_done;
|
||||
private:
|
||||
// Sub state in disposed, we need to wait for thread to quit.
|
||||
bool stopping_;
|
||||
SrsContextId stopping_cid_;
|
||||
public:
|
||||
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h);
|
||||
SrsFastCoroutine(std::string n, ISrsCoroutineHandler* h, SrsContextId cid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue