mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix ffmpeg log fd leak, always close log_fd. 0.9.94
This commit is contained in:
parent
74e6e28993
commit
7004510cc7
3 changed files with 134 additions and 139 deletions
|
@ -64,8 +64,6 @@ SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
|
|||
abitrate = 0;
|
||||
asample_rate = 0;
|
||||
achannels = 0;
|
||||
|
||||
log_fd = -1;
|
||||
}
|
||||
|
||||
SrsFFMPEG::~SrsFFMPEG()
|
||||
|
@ -375,6 +373,7 @@ int SrsFFMPEG::start()
|
|||
// child process: ffmpeg encoder engine.
|
||||
if (pid == 0) {
|
||||
// redirect logs to file.
|
||||
int log_fd = -1;
|
||||
int flags = O_CREAT|O_WRONLY|O_APPEND;
|
||||
mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH;
|
||||
if ((log_fd = ::open(log_file.c_str(), flags, mode)) < 0) {
|
||||
|
@ -392,6 +391,8 @@ int SrsFFMPEG::start()
|
|||
srs_error("dup2 encoder file failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
// close log fd
|
||||
::close(log_fd);
|
||||
// close other fds
|
||||
// TODO: do in right way.
|
||||
for (int i = 3; i < 1024; i++) {
|
||||
|
@ -456,11 +457,6 @@ int SrsFFMPEG::cycle()
|
|||
|
||||
void SrsFFMPEG::stop()
|
||||
{
|
||||
if (log_fd > 0) {
|
||||
::close(log_fd);
|
||||
log_fd = -1;
|
||||
}
|
||||
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ private:
|
|||
pid_t pid;
|
||||
private:
|
||||
std::string log_file;
|
||||
int log_fd;
|
||||
private:
|
||||
std::string ffmpeg;
|
||||
std::string _iparams;
|
||||
|
|
2
trunk/src/core/srs_core.hpp
Normal file → Executable file
2
trunk/src/core/srs_core.hpp
Normal file → Executable file
|
@ -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 "93"
|
||||
#define VERSION_REVISION "94"
|
||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "srs"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue