mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
fix bugs
This commit is contained in:
parent
fabcc91a0e
commit
5ac8177ce6
6 changed files with 28 additions and 13 deletions
|
@ -410,7 +410,7 @@ int SrsRtmpConn::do_cycle()
|
||||||
srs_info("discovery app success. schema=%s, vhost=%s, port=%s, app=%s",
|
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());
|
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;
|
ret = ERROR_RTMP_REQ_TCURL;
|
||||||
srs_error("discovery tcUrl failed. "
|
srs_error("discovery tcUrl failed. "
|
||||||
"tcUrl=%s, schema=%s, vhost=%s, port=%d, app=%s, ret=%d",
|
"tcUrl=%s, schema=%s, vhost=%s, port=%d, app=%s, ret=%d",
|
||||||
|
|
13
trunk/src/app/srs_app_server.cpp
Executable file → Normal file
13
trunk/src/app/srs_app_server.cpp
Executable file → Normal file
|
@ -968,7 +968,7 @@ int SrsServer::do_cycle()
|
||||||
|
|
||||||
// the deamon thread, update the time cache
|
// the deamon thread, update the time cache
|
||||||
while (true) {
|
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);
|
srs_error("cycle handle failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1255,14 +1255,19 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
||||||
|
|
||||||
int fd = st_netfd_fileno(client_stfd);
|
int fd = st_netfd_fileno(client_stfd);
|
||||||
|
|
||||||
|
// check connection limitation.
|
||||||
int max_connections = _srs_config->get_max_connections();
|
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) {
|
if ((int)conns.size() >= max_connections) {
|
||||||
srs_error("exceed the max connections, drop client: "
|
srs_error("exceed the max connections, drop client: "
|
||||||
"clients=%d, max=%d, fd=%d", (int)conns.size(), max_connections, fd);
|
"clients=%d, max=%d, fd=%d", (int)conns.size(), max_connections, fd);
|
||||||
|
|
||||||
srs_close_stfd(client_stfd);
|
srs_close_stfd(client_stfd);
|
||||||
|
return ERROR_SUCCESS;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid fd leak when fork.
|
// avoid fd leak when fork.
|
||||||
|
|
|
@ -225,7 +225,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* do on_cycle while server doing cycle.
|
* 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -440,7 +440,7 @@ int SrsTcpClient::connect(string host, int port, int64_t timeout)
|
||||||
|
|
||||||
// connect host.
|
// connect host.
|
||||||
if ((ret = srs_socket_connect(host, port, timeout, &stfd)) != ERROR_SUCCESS) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,9 @@ vector<string> srs_string_split(string str, string flag)
|
||||||
string s = str;
|
string s = str;
|
||||||
|
|
||||||
while ((pos = s.find(flag)) != string::npos) {
|
while ((pos = s.find(flag)) != string::npos) {
|
||||||
|
if (pos != 0) {
|
||||||
arr.push_back(s.substr(0, pos));
|
arr.push_back(s.substr(0, pos));
|
||||||
|
}
|
||||||
s = s.substr(pos + flag.length());
|
s = s.substr(pos + flag.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +408,9 @@ vector<string> srs_string_split(string str, vector<string> flags)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pos != 0) {
|
||||||
arr.push_back(s.substr(0, pos));
|
arr.push_back(s.substr(0, pos));
|
||||||
|
}
|
||||||
s = s.substr(pos + flag.length());
|
s = s.substr(pos + flag.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ extern bool srs_string_starts_with(std::string str, std::string flag0, std::stri
|
||||||
extern bool srs_string_starts_with(std::string str, std::string flag0, std::string flag1, std::string flag2, std::string flag3);
|
extern bool srs_string_starts_with(std::string str, std::string flag0, std::string flag1, std::string flag2, std::string flag3);
|
||||||
// whether string contains with
|
// whether string contains with
|
||||||
extern bool srs_string_contains(std::string str, std::string flag);
|
extern bool srs_string_contains(std::string str, std::string flag);
|
||||||
|
// find the min match in str for flags.
|
||||||
|
extern std::string srs_string_min_match(std::string str, std::vector<std::string> flags);
|
||||||
// split the string by flag to array.
|
// split the string by flag to array.
|
||||||
extern std::vector<std::string> srs_string_split(std::string str, std::string flag);
|
extern std::vector<std::string> srs_string_split(std::string str, std::string flag);
|
||||||
extern std::vector<std::string> srs_string_split(std::string str, std::vector<std::string> flags);
|
extern std::vector<std::string> srs_string_split(std::string str, std::vector<std::string> flags);
|
||||||
|
@ -97,9 +99,9 @@ extern int srs_create_dir_recursively(std::string dir);
|
||||||
|
|
||||||
// whether path exists.
|
// whether path exists.
|
||||||
extern bool srs_path_exists(std::string path);
|
extern bool srs_path_exists(std::string path);
|
||||||
// get the dirname of path, for instance, filename("/live/livestream")="/live"
|
// get the dirname of path, for instance, dirname("/live/livestream")="/live"
|
||||||
extern std::string srs_path_dirname(std::string path);
|
extern std::string srs_path_dirname(std::string path);
|
||||||
// get the basename of path, for instance, filename("/live/livestream")="livestream"
|
// get the basename of path, for instance, basename("/live/livestream")="livestream"
|
||||||
extern std::string srs_path_basename(std::string path);
|
extern std::string srs_path_basename(std::string path);
|
||||||
// get the filename of path, for instance, filename("livestream.flv")="livestream"
|
// get the filename of path, for instance, filename("livestream.flv")="livestream"
|
||||||
extern std::string srs_path_filename(std::string path);
|
extern std::string srs_path_filename(std::string path);
|
||||||
|
|
Loading…
Reference in a new issue