mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +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",
|
||||
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
17
trunk/src/app/srs_app_server.cpp
Executable file → Normal 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.
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,9 @@ vector<string> srs_string_split(string str, string flag)
|
|||
string s = str;
|
||||
|
||||
while ((pos = s.find(flag)) != string::npos) {
|
||||
arr.push_back(s.substr(0, pos));
|
||||
if (pos != 0) {
|
||||
arr.push_back(s.substr(0, pos));
|
||||
}
|
||||
s = s.substr(pos + flag.length());
|
||||
}
|
||||
|
||||
|
@ -406,7 +408,9 @@ vector<string> srs_string_split(string str, vector<string> flags)
|
|||
break;
|
||||
}
|
||||
|
||||
arr.push_back(s.substr(0, pos));
|
||||
if (pos != 0) {
|
||||
arr.push_back(s.substr(0, pos));
|
||||
}
|
||||
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);
|
||||
// whether string contains with
|
||||
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.
|
||||
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);
|
||||
|
@ -97,9 +99,9 @@ extern int srs_create_dir_recursively(std::string dir);
|
|||
|
||||
// whether path exists.
|
||||
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);
|
||||
// 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);
|
||||
// get the filename of path, for instance, filename("livestream.flv")="livestream"
|
||||
extern std::string srs_path_filename(std::string path);
|
||||
|
|
Loading…
Reference in a new issue