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
2014-05-02 12:29:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d74f01e2d18191cb8b0e9bbe024e24a4355c6366
d74f01e2
1 parent
ac3d0d5b
fix signal bug, break for gmc. fix SrsMessage leak, use common message to free payload. to 0.9.88
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
86 行增加
和
50 行删除
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/core/srs_core.hpp
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
trunk/src/rtmp/srs_protocol_rtmp_stack.hpp
trunk/src/app/srs_app_server.cpp
查看文件 @
d74f01e
...
...
@@ -532,6 +532,59 @@ int SrsServer::ingest()
int
SrsServer
::
cycle
()
{
int
ret
=
ERROR_SUCCESS
;
ret
=
do_cycle
();
#ifdef SRS_AUTO_INGEST
ingester
->
stop
();
#endif
return
ret
;
}
void
SrsServer
::
remove
(
SrsConnection
*
conn
)
{
std
::
vector
<
SrsConnection
*>::
iterator
it
=
std
::
find
(
conns
.
begin
(),
conns
.
end
(),
conn
);
if
(
it
!=
conns
.
end
())
{
conns
.
erase
(
it
);
}
srs_info
(
"conn removed. conns=%d"
,
(
int
)
conns
.
size
());
// all connections are created by server,
// so we free it here.
srs_freep
(
conn
);
}
void
SrsServer
::
on_signal
(
int
signo
)
{
if
(
signo
==
SIGNAL_RELOAD
)
{
signal_reload
=
true
;
return
;
}
if
(
signo
==
SIGINT
)
{
#ifdef SRS_AUTO_GPERF_MC
srs_trace
(
"gmc is on, main cycle will terminate normally."
);
signal_gmc_stop
=
true
;
#else
srs_trace
(
"user terminate program"
);
exit
(
0
);
#endif
return
;
}
if
(
signo
==
SIGTERM
)
{
srs_trace
(
"user terminate program"
);
exit
(
0
);
return
;
}
}
int
SrsServer
::
do_cycle
()
{
int
ret
=
ERROR_SUCCESS
;
// find the max loop
int
max
=
srs_max
(
0
,
SRS_SYS_TIME_RESOLUTION_MS_TIMES
);
...
...
@@ -551,7 +604,7 @@ int SrsServer::cycle()
// because directly exit will cause core-dump.
#ifdef SRS_AUTO_GPERF_MC
if
(
signal_gmc_stop
)
{
break
;
return
ret
;
}
#endif
...
...
@@ -582,53 +635,9 @@ int SrsServer::cycle()
}
}
#ifdef SRS_AUTO_INGEST
ingester
->
stop
();
#endif
return
ret
;
}
void
SrsServer
::
remove
(
SrsConnection
*
conn
)
{
std
::
vector
<
SrsConnection
*>::
iterator
it
=
std
::
find
(
conns
.
begin
(),
conns
.
end
(),
conn
);
if
(
it
!=
conns
.
end
())
{
conns
.
erase
(
it
);
}
srs_info
(
"conn removed. conns=%d"
,
(
int
)
conns
.
size
());
// all connections are created by server,
// so we free it here.
srs_freep
(
conn
);
}
void
SrsServer
::
on_signal
(
int
signo
)
{
if
(
signo
==
SIGNAL_RELOAD
)
{
signal_reload
=
true
;
return
;
}
if
(
signo
==
SIGINT
)
{
#ifdef SRS_AUTO_GPERF_MC
srs_trace
(
"gmc is on, main cycle will terminate normally."
);
signal_gmc_stop
=
true
;
#else
srs_trace
(
"user terminate program"
);
exit
(
0
);
#endif
return
;
}
if
(
signo
==
SIGTERM
)
{
srs_trace
(
"user terminate program"
);
exit
(
0
);
return
;
}
}
int
SrsServer
::
listen_rtmp
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
d74f01e
...
...
@@ -140,6 +140,7 @@ public:
virtual
void
remove
(
SrsConnection
*
conn
);
virtual
void
on_signal
(
int
signo
);
private
:
virtual
int
do_cycle
();
virtual
int
listen_rtmp
();
virtual
int
listen_http_api
();
virtual
int
listen_http_stream
();
...
...
trunk/src/core/srs_core.hpp
查看文件 @
d74f01e
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "8
7
"
#define VERSION_REVISION "8
8
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "srs"
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
查看文件 @
d74f01e
...
...
@@ -759,7 +759,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id)
}
// to message
SrsMessage
*
msg
=
new
SrsMessage
();
SrsMessage
*
msg
=
new
Srs
Common
Message
();
msg
->
payload
=
(
int8_t
*
)
payload
;
msg
->
size
=
(
int32_t
)
size
;
...
...
@@ -975,7 +975,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
bool
is_first_chunk_of_msg
=
false
;
if
(
!
chunk
->
msg
)
{
is_first_chunk_of_msg
=
true
;
chunk
->
msg
=
new
SrsMessage
();
chunk
->
msg
=
new
Srs
Common
Message
();
srs_verbose
(
"create message for new chunk, fmt=%d, cid=%d"
,
fmt
,
chunk
->
cid
);
}
...
...
@@ -1532,7 +1532,16 @@ SrsMessage::SrsMessage()
}
SrsMessage
::~
SrsMessage
()
{
{
}
SrsCommonMessage
::
SrsCommonMessage
()
{
}
SrsCommonMessage
::~
SrsCommonMessage
()
{
srs_freepa
(
payload
);
}
SrsSharedPtrMessage
::
__SrsSharedPtr
::
__SrsSharedPtr
()
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.hpp
查看文件 @
d74f01e
...
...
@@ -325,6 +325,12 @@ public:
* message is raw data RTMP message, bytes oriented,
* protcol always recv RTMP message, and can send RTMP message or RTMP packet.
* the shared-ptr message is a special RTMP message, use ref-count for performance issue.
*
* @remark, never directly new SrsMessage, the constructor is protected,
* for in the SrsMessage, we never know whether we should free the message,
* for SrsCommonMessage, we should free the payload,
* while for SrsSharedPtrMessage, we should use ref-count to free it.
* so, use these two concrete message, SrsCommonMessage or SrsSharedPtrMessage instread.
*/
class
SrsMessage
{
...
...
@@ -341,12 +347,23 @@ public:
*/
int32_t
size
;
int8_t
*
payload
;
p
ublic
:
p
rotected
:
SrsMessage
();
public
:
virtual
~
SrsMessage
();
};
/**
* the common message used free the payload in common way.
*/
class
SrsCommonMessage
:
public
SrsMessage
{
public
:
SrsCommonMessage
();
virtual
~
SrsCommonMessage
();
};
/**
* shared ptr message.
* for audio/video/data message that need less memory copy.
* and only for output.
...
...
请
注册
或
登录
后发表评论