[asterisk-bugs] [Asterisk 0015181]: file convert leaks input file descriptor
Asterisk Bug Tracker
noreply at bugs.digium.com
Mon May 25 05:39:32 CDT 2009
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=15181
======================================================================
Reported By: jkroon
Assigned To: russell
======================================================================
Project: Asterisk
Issue ID: 15181
Category: Resources/res_convert
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
Asterisk Version: 1.6.0.9
Regression: No
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2009-05-22 09:18 CDT
Last Modified: 2009-05-25 05:39 CDT
======================================================================
Summary: file convert leaks input file descriptor
Description:
when issueing a file convert it seems that asterisk is leaking the input
file descriptor. As a test I copied a .g729 file into /tmp
(/tmp/test.g729), the rest follows:
gabriel ~ # ls -l /tmp/test.*
-rw-r--r-- 1 root root 3380 May 22 16:10 /tmp/test.g729
gabriel ~ # ls -l /proc/$(pidof asterisk)/fd/ | grep test
gabriel ~ # asterisk -rx "file convert /tmp/test.g729 /tmp/test.wav"
Converted /tmp/test.g729 to /tmp/test.wav in 12ms
gabriel ~ # ls -l /proc/$(pidof asterisk)/fd/ | grep test
lrwx------ 1 asterisk asterisk 64 May 22 16:10 179 -> /tmp/test.g729
gabriel ~ # ls -l /tmp/test.*
-rw-r--r-- 1 root root 3380 May 22 16:10 /tmp/test.g729
-rw-r--r-- 1 asterisk asterisk 54124 May 22 16:12 /tmp/test.wav
gabriel ~ #
I'll take a peek at the code a little later, for now I just need to have
it reported. I don't think this was the case in 1.6.0.3 but I'll need to
go find an installation to confirm.
======================================================================
----------------------------------------------------------------------
(0105366) jkroon (reporter) - 2009-05-25 05:39
https://issues.asterisk.org/view.php?id=15181#c105366
----------------------------------------------------------------------
Ok, I think I managed to figure out what's going on, please do confirm.
Based on a diff of 1.6.0.3 and 1.6.0.9 res/res_convert.c is identical.
However, main/file.c has changed a little. In particular, there were
changes made to ast_closestream, in particular, a large block of code was
replaced with this:
+ if (ast_test_flag(&f->fr, AST_FRFLAG_FROM_FILESTREAM)) {
+ /* If this flag is still set, it essentially means that the reference
+ * count of f is non-zero. We can't destroy this filestream until
+ * whatever is using the filestream's frame has finished.
+ *
+ * Since this was called, however, we need to remove the reference
from
+ * when this filestream was first allocated. That way, when the
embedded
+ * frame is freed, the refcount will reach 0 and we can finish
destroying
+ * this filestream properly.
+ */
+ ao2_ref(f, -1);
+ return 0;
Which is basically checking the same reference flag that is being
incremented in ast_readframe. The appropriate function apparently to
decrement this reference counter is ast_filestream_frame_freed.
As a side note btw, the entire ast_closestream (unless test_flag has side
effects) can be reduced to ao2_ref(f, -1); return 0;, however, that is not
related to the issue at hand, I think.
I suspect the ast_filestream_frame_freed function needs to be called from
somewhere, I'm just not 100 % sure from where.
Issue History
Date Modified Username Field Change
======================================================================
2009-05-25 05:39 jkroon Note Added: 0105366
======================================================================
More information about the asterisk-bugs
mailing list