mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
refine code for bug #217, use recv thread to set the timeout.
This commit is contained in:
parent
5408169b6e
commit
3e81e6e0f1
3 changed files with 30 additions and 17 deletions
|
@ -96,3 +96,27 @@ int SrsRecvThread::cycle()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRecvThread::on_thread_start()
|
||||||
|
{
|
||||||
|
// the multiple messages writev improve performance large,
|
||||||
|
// but the timeout recv will cause 33% sys call performance,
|
||||||
|
// to use isolate thread to recv, can improve about 33% performance.
|
||||||
|
// @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||||
|
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
||||||
|
rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
|
||||||
|
|
||||||
|
// disable the protocol auto response,
|
||||||
|
// for the isolate recv thread should never send any messages.
|
||||||
|
rtmp->set_auto_response(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsRecvThread::on_thread_stop()
|
||||||
|
{
|
||||||
|
// enable the protocol auto response,
|
||||||
|
// for the isolate recv thread terminated.
|
||||||
|
rtmp->set_auto_response(true);
|
||||||
|
|
||||||
|
// reset the timeout to pulse mode.
|
||||||
|
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ public:
|
||||||
virtual int start();
|
virtual int start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual int cycle();
|
virtual int cycle();
|
||||||
|
public:
|
||||||
|
virtual void on_thread_start();
|
||||||
|
virtual void on_thread_stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -498,21 +498,11 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// the multiple messages writev improve performance large,
|
|
||||||
// but the timeout recv will cause 33% sys call performance,
|
|
||||||
// to use isolate thread to recv, can improve about 33% performance.
|
|
||||||
// @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
|
||||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
|
||||||
//rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
|
||||||
rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
|
|
||||||
|
|
||||||
// disable the protocol auto response,
|
|
||||||
// for the isolate recv thread should never send any messages.
|
|
||||||
rtmp->set_auto_response(false);
|
|
||||||
|
|
||||||
// use isolate thread to recv,
|
// use isolate thread to recv,
|
||||||
// start isolate recv thread.
|
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
||||||
SrsRecvThread trd(rtmp);
|
SrsRecvThread trd(rtmp);
|
||||||
|
|
||||||
|
// start isolate recv thread.
|
||||||
if ((ret = trd.start()) != ERROR_SUCCESS) {
|
if ((ret = trd.start()) != ERROR_SUCCESS) {
|
||||||
srs_error("start isolate recv thread failed. ret=%d", ret);
|
srs_error("start isolate recv thread failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -524,10 +514,6 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
// stop isolate recv thread
|
// stop isolate recv thread
|
||||||
trd.stop();
|
trd.stop();
|
||||||
|
|
||||||
// enable the protocol auto response,
|
|
||||||
// for the isolate recv thread terminated.
|
|
||||||
rtmp->set_auto_response(true);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue