Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-12-08 18:32:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5ac8177ce6960cde323348acc609887c5acbe888
5ac8177c
1 parent
fabcc91a
fix bugs
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
28 行增加
和
13 行删除
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_st.cpp
trunk/src/kernel/srs_kernel_utility.cpp
trunk/src/kernel/srs_kernel_utility.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
5ac8177
...
...
@@ -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"
,
...
...
trunk/src/app/srs_app_server.cpp
100755 → 100644
查看文件 @
5ac8177
...
...
@@ -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.
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
5ac8177
...
...
@@ -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
;
};
/**
...
...
trunk/src/app/srs_app_st.cpp
查看文件 @
5ac8177
...
...
@@ -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
;
}
...
...
trunk/src/kernel/srs_kernel_utility.cpp
查看文件 @
5ac8177
...
...
@@ -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
());
}
...
...
trunk/src/kernel/srs_kernel_utility.hpp
查看文件 @
5ac8177
...
...
@@ -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,
file
name("/live/livestream")="/live"
// get the dirname of path, for instance,
dir
name("/live/livestream")="/live"
extern
std
::
string
srs_path_dirname
(
std
::
string
path
);
// get the basename of path, for instance,
fil
ename("/live/livestream")="livestream"
// get the basename of path, for instance,
bas
ename("/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
);
...
...
请
注册
或
登录
后发表评论