mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix the thread stop bug, must wait when not joinable.
This commit is contained in:
parent
d317528af9
commit
66837ffa6e
3 changed files with 17 additions and 14 deletions
|
@ -539,8 +539,6 @@ void SrsServer::destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_freep(signal_manager);
|
srs_freep(signal_manager);
|
||||||
|
|
||||||
srs_freep(handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsServer::dispose()
|
void SrsServer::dispose()
|
||||||
|
|
|
@ -293,10 +293,14 @@ private:
|
||||||
virtual void dispose();
|
virtual void dispose();
|
||||||
// server startup workflow, @see run_master()
|
// server startup workflow, @see run_master()
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* initialize server with callback handler.
|
||||||
|
* @remark user must free the cycle handler.
|
||||||
|
*/
|
||||||
virtual int initialize(ISrsServerCycle* cycle_handler);
|
virtual int initialize(ISrsServerCycle* cycle_handler);
|
||||||
|
virtual int initialize_st();
|
||||||
virtual int initialize_signal();
|
virtual int initialize_signal();
|
||||||
virtual int acquire_pid_file();
|
virtual int acquire_pid_file();
|
||||||
virtual int initialize_st();
|
|
||||||
virtual int listen();
|
virtual int listen();
|
||||||
virtual int register_signal();
|
virtual int register_signal();
|
||||||
virtual int http_handle();
|
virtual int http_handle();
|
||||||
|
|
|
@ -129,19 +129,20 @@ namespace internal {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
srs_warn("core: ignore join thread failed.");
|
srs_warn("core: ignore join thread failed.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// wait the thread actually terminated.
|
// wait the thread actually terminated.
|
||||||
// sometimes the thread join return -1, for example,
|
// sometimes the thread join return -1, for example,
|
||||||
// when thread use st_recvfrom, the thread join return -1.
|
// when thread use st_recvfrom, the thread join return -1.
|
||||||
// so here, we use a variable to ensure the thread stopped.
|
// so here, we use a variable to ensure the thread stopped.
|
||||||
while (!really_terminated) {
|
// @remark even the thread not joinable, we must ensure the thread stopped when stop.
|
||||||
st_usleep(10 * 1000);
|
while (!really_terminated) {
|
||||||
|
st_usleep(10 * 1000);
|
||||||
|
|
||||||
if (really_terminated) {
|
if (really_terminated) {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
srs_warn("core: wait thread to actually terminated");
|
|
||||||
}
|
}
|
||||||
|
srs_warn("core: wait thread to actually terminated");
|
||||||
}
|
}
|
||||||
|
|
||||||
tid = NULL;
|
tid = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue