1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00
This commit is contained in:
winlin 2015-12-08 18:32:37 +08:00
parent fabcc91a0e
commit 5ac8177ce6
6 changed files with 28 additions and 13 deletions

View file

@ -410,7 +410,7 @@ int SrsRtmpConn::do_cycle()
srs_info("discovery app success. schema=%s, vhost=%s, port=%s, app=%s",
req->schema.c_str(), req->vhost.c_str(), req->port.c_str(), req->app.c_str());
if (req->schema.empty() || req->vhost.empty() || req->app.empty()) {
if (req->schema.empty() || req->vhost.empty() || req->port == 0 || req->app.empty()) {
ret = ERROR_RTMP_REQ_TCURL;
srs_error("discovery tcUrl failed. "
"tcUrl=%s, schema=%s, vhost=%s, port=%d, app=%s, ret=%d",

17
trunk/src/app/srs_app_server.cpp Executable file → Normal file
View file

@ -968,11 +968,11 @@ int SrsServer::do_cycle()
// the deamon thread, update the time cache
while (true) {
if(handler && (ret = handler->on_cycle((int)conns.size())) != ERROR_SUCCESS){
if (handler && (ret = handler->on_cycle()) != ERROR_SUCCESS) {
srs_error("cycle handle failed. ret=%d", ret);
return ret;
}
// the interval in config.
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL);
@ -1254,15 +1254,20 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
int ret = ERROR_SUCCESS;
int fd = st_netfd_fileno(client_stfd);
// check connection limitation.
int max_connections = _srs_config->get_max_connections();
if (handler && (ret = handler->on_accept_client(max_connections, (int)conns.size()) != ERROR_SUCCESS)) {
srs_error("handle accept client failed, drop client: "
"clients=%d, max=%d, fd=%d. ret=%d", (int)conns.size(), max_connections, fd, ret);
srs_close_stfd(client_stfd);
return ERROR_SUCCESS;
}
if ((int)conns.size() >= max_connections) {
srs_error("exceed the max connections, drop client: "
"clients=%d, max=%d, fd=%d", (int)conns.size(), max_connections, fd);
srs_close_stfd(client_stfd);
return ret;
return ERROR_SUCCESS;
}
// avoid fd leak when fork.

View file

@ -225,7 +225,11 @@ public:
/**
* do on_cycle while server doing cycle.
*/
virtual int on_cycle(int connections) = 0;
virtual int on_cycle() = 0;
/**
* callback the handler when got client.
*/
virtual int on_accept_client(int conf_conns, int curr_conns) = 0;
};
/**

View file

@ -440,7 +440,7 @@ int SrsTcpClient::connect(string host, int port, int64_t timeout)
// connect host.
if ((ret = srs_socket_connect(host, port, timeout, &stfd)) != ERROR_SUCCESS) {
srs_error("mpegts: connect server %s:%d failed. ret=%d", host.c_str(), port, ret);
srs_error("connect server %s:%d failed. ret=%d", host.c_str(), port, ret);
return ret;
}