winlin

enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182

... ... @@ -342,6 +342,7 @@ Remark:
## History
* v2.0, 2015-08-12, enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182
* v2.0, 2015-08-11, for [#442](https://github.com/simple-rtmp-server/srs/issues/442) support kickoff connected client. 2.0.181
* v2.0, 2015-07-21, for [#169](https://github.com/simple-rtmp-server/srs/issues/169) support default values for transcode. 2.0.180
* v2.0, 2015-07-21, fix [#435](https://github.com/simple-rtmp-server/srs/issues/435) add pageUrl for HTTP callback on_play.
... ...
... ... @@ -851,6 +851,10 @@ vhost min.delay.com {
# drop the old whole gop.
# default: 30
queue_length 10;
# whether enable the TCP_NODELAY
# if on, set the nodelay of fd by setsockopt
# default: off
tcp_nodelay on;
}
# the vhost for antisuck.
... ...
... ... @@ -12,4 +12,5 @@ vhost __defaultVhost__ {
enabled off;
}
mw_latency 100;
tcp_nodelay on;
}
... ...
... ... @@ -1750,7 +1750,7 @@ int SrsConfig::check_config()
&& n != "time_jitter" && n != "mix_correct"
&& n != "atc" && n != "atc_auto"
&& n != "debug_srs_upnode"
&& n != "mr" && n != "mw_latency" && n != "min_latency"
&& n != "mr" && n != "mw_latency" && n != "min_latency" && n != "tcp_nodelay"
&& n != "security" && n != "http_remux"
&& n != "http" && n != "http_static"
&& n != "hds"
... ... @@ -2489,6 +2489,23 @@ bool SrsConfig::get_realtime_enabled(string vhost)
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
bool SrsConfig::get_tcp_nodelay(string vhost)
{
static bool DEFAULT = false;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("tcp_nodelay");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
int SrsConfig::get_global_chunk_size()
{
SrsConfDirective* conf = root->get("chunk_size");
... ...
... ... @@ -522,6 +522,10 @@ public:
*/
// TODO: FIXME: add utest for min_latency.
virtual bool get_realtime_enabled(std::string vhost);
/**
* whether enable tcp nodelay for all clients of vhost.
*/
virtual bool get_tcp_nodelay(std::string vhost);
private:
/**
* get the global chunk size.
... ...
... ... @@ -591,7 +591,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost));
// set the sock options.
play_set_sock_options();
set_sock_options();
while (!disposed) {
// collect elapse for pithy print.
... ... @@ -769,6 +769,9 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
srs_error("start isolate recv thread failed. ret=%d", ret);
return ret;
}
// set the sock options.
set_sock_options();
int64_t nb_msgs = 0;
while (!disposed) {
... ... @@ -1093,10 +1096,10 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
mw_sleep = sleep_ms;
}
void SrsRtmpConn::play_set_sock_options()
void SrsRtmpConn::set_sock_options()
{
if (_srs_config->get_tcp_nodelay(req->vhost)) {
#ifdef SRS_PERF_TCP_NODELAY
if (true) {
int fd = st_netfd_fileno(stfd);
socklen_t nb_v = sizeof(int);
... ... @@ -1112,8 +1115,10 @@ void SrsRtmpConn::play_set_sock_options()
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, &nb_v);
srs_trace("set TCP_NODELAY %d=>%d", ov, v);
}
#else
srs_warn("SRS_PERF_TCP_NODELAY is disabled but tcp_nodelay configed.");
#endif
}
}
int SrsRtmpConn::check_edge_token_traverse_auth()
... ...
... ... @@ -119,7 +119,7 @@ private:
virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool vhost_is_edge);
virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
virtual void change_mw_sleep(int sleep_ms);
virtual void play_set_sock_options();
virtual void set_sock_options();
private:
virtual int check_edge_token_traverse_auth();
virtual int connect_server(int origin_index, st_netfd_t* pstsock);
... ...
... ... @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 181
#define VERSION_REVISION 182
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
... ...
... ... @@ -163,12 +163,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//#undef SRS_PERF_COMPLEX_SEND
#define SRS_PERF_COMPLEX_SEND
/**
* whether enable the TCP_NODELAY
* user maybe need send small tcp packet for some network.
* @see https://github.com/simple-rtmp-server/srs/issues/320
*/
//#define SRS_PERF_TCP_NODELAY
* whether enable the TCP_NODELAY
* user maybe need send small tcp packet for some network.
* @see https://github.com/simple-rtmp-server/srs/issues/320
*/
#undef SRS_PERF_TCP_NODELAY
#define SRS_PERF_TCP_NODELAY
/**
* set the socket send buffer,
* to force the server to send smaller tcp packet.
... ...