1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00

merge from 2.0

This commit is contained in:
winlin 2015-08-12 13:23:00 +08:00
commit 653afd0700
9 changed files with 46 additions and 13 deletions

View file

@ -342,6 +342,8 @@ 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.
* v2.0, 2015-07-20, refine the hls, ignore packet when no sequence header. 2.0.179

View file

@ -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.

View file

@ -12,4 +12,5 @@ vhost __defaultVhost__ {
enabled off;
}
mw_latency 100;
tcp_nodelay on;
}

View file

@ -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");

View file

@ -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.

View file

@ -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.
@ -770,6 +770,9 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
return ret;
}
// set the sock options.
set_sock_options();
int64_t nb_msgs = 0;
while (!disposed) {
pprint->elapse();
@ -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,9 +1115,11 @@ 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()
{

View file

@ -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);

View file

@ -826,12 +826,12 @@ int SrsServer::http_handle()
// TODO: FIXME: for console.
// TODO: FIXME: support reload.
std::string dir = _srs_config->get_http_stream_dir() + "/srs-console";
std::string dir = _srs_config->get_http_stream_dir() + "/console";
if ((ret = http_api_mux->handle("/console/", new SrsHttpFileServer(dir))) != ERROR_SUCCESS) {
srs_error("http: mount console dir=%s failed. ret=%d", dir.c_str(), ret);
return ret;
}
srs_trace("http: console mount to %s", dir.c_str());
srs_trace("http: api mount /console to %s", dir.c_str());
#endif
return ret;

View file

@ -167,8 +167,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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
#undef SRS_PERF_TCP_NODELAY
#define SRS_PERF_TCP_NODELAY
/**
* set the socket send buffer,
* to force the server to send smaller tcp packet.